☰
Python Across Disciplines
with Python + AI Tool   
×
Table of Contents

1.1.   Introduction 1.2.   About the Author & Contact Info 1.3.   Book Conventions 1.4.   What (Who) is a Programmer? 1.5.   Programming Across Disciplines 1.6.   Foundational Computing Concepts 1.7.   About Python 1.8.   First Steps 1.8.1 Computer Setup 1.8.2 Python print() Function 1.8.3 Comments
2.1. About Data 2.2. Data Types 2.3. Variables 2.4. User Input 2.5. Data Structures (DS)         2.5.1. DS Concepts         2.5.2. Lists         2.5.3. Dictionaries         2.5.4. Others 2.6. Files         2.6.1. Files & File Systems         2.6.2. Python File Object         2.6.3. Data Files 2.7. Databases
3.1. About Processing 3.2. Decisions         3.2.1 Decision Concepts         3.2.2 Conditions & Booleans         3.2.3 if Statements         3.2.4 if-else Statements         3.2.5 if-elif-else Statements         3.2.6 In-Line if Statements 3.3. Repetition (a.k.a. Loops)         3.3.1  Repetition Concepts         3.3.2  while Loops         3.3.3  for Loops         3.3.4  Nested Loops         3.3.5  Validating User Input 3.4. Functions         3.4.1  Function Concepts         3.4.2  Built-In Functions         3.4.3  Programmer Defined Functions 3.5. Libraries         3.5.1  Library Concepts         3.5.2  Standard Library         3.5.3  External Libraries 3.6. Processing Case Studies         3.6.1  Case Studies         3.6.2  Parsing Data
4.1. About Output 4.2. Advanced Printing 4.3. Data Visualization   4.4  Sound
  4.5  Graphics
  4.6  Video
  4.7  Web Output
  4.8  PDFs & Documents
  4.9  Dashboards
  4.10  Animation & Games
  4.11  Text to Speech

5.1 About Disciplines 5.2 Accounting 5.3 Architecture 5.4 Art 5.5 Artificial Intelligence (AI) 5.6 Autonomous Vehicles 5.7 Bioinformatics 5.8 Biology 5.9 Bitcoin 5.10 Blockchain 5.11 Business 5.12 Business Analytics 5.13 Chemistry 5.14 Communication 5.15 Computational Photography 5.16 Computer Science 5.17 Creative Writing 5.18 Cryptocurrency 5.19 Cultural Studies 5.20 Data Analytics 5.21 Data Engineering 5.22 Data Science 5.23 Data Visualization 5.24 Drone Piloting 5.25 Economics 5.26 Education 5.27 Engineering 5.28 English 5.29 Entrepreneurship 5.30 Environmental Studies 5.31 Exercise Science 5.32 Film 5.33 Finance 5.34 Gaming 5.35 Gender Studies 5.36 Genetics 5.37 Geography 5.38 Geology 5.39 Geospatial Analysis ☯ 5.40 History 5.41 Humanities 5.42 Information Systems 5.43 Languages 5.44 Law 5.45 Linguistics 5.46 Literature 5.47 Machine Learning 5.48 Management 5.49 Marketing 5.50 Mathematics 5.51 Medicine 5.52 Military 5.53 Model Railroading 5.54 Music 5.55 Natural Language Processing (NLP) 5.56 Network Analysis 5.57 Neural Networks 5.58 Neurology 5.59 Nursing 5.60 Pharmacology 5.61 Philosophy 5.62 Physiology 5.63 Politics 5.64 Psychiatry 5.65 Psychology 5.66 Real Estate 5.67 Recreation 5.68 Remote Control (RC) Vehicles 5.69 Rhetoric 5.70 Science 5.71 Sociology 5.72 Sports 5.73 Stock Trading 5.74 Text Mining 5.75 Weather 5.76 Writing
6.1. Databases         6.1.1 Overview of Databases         6.1.2 SQLite Databases         6.1.3 Querying a SQLite Database         6.1.4 CRUD Operations with SQLite         6.1.5 Connecting to Other Databases
Built-In Functions Conceptss Data Types Date & Time Format Codes Dictionary Methods Escape Sequences File Access Modes File Object Methods Python Keywords List Methods Operators Set Methods String Methods Tuple Methods Glossary Index Appendices   Software Install & Setup
  Coding Tools:
  A.  Python    B.  Google CoLaboratory    C.  Visual Studio Code    D.  PyCharm IDE    E.  Git    F.  GitHub 
  Database Tools:
  G.  SQLite Database    H.  MySQL Database 


Python Across Disciplines
by John Gordon © 2023

Table of Contents

Table of Contents  »  Appendices : GitHub

Appendix F

GitHub   


Overview

As explained above, Git is the underlying source code control technology that allows us to have repositories, clone them and collaborate with others in our programming projects. GitHub is one of many services that provide cloud-based distributed storage and sharing of Git repositories. It is important to understand the difference between Git and GitHub. As a student, you can use the GitHub services for free and build up a portfolio of projects from your classes which you can use as a demonstration of your skills for job interviews, internship applications, etc.

Creating a GitHub Account

In order to use GitHub, you'll need to create an account. You can create a free account that we can use to collaborate with our projects in this class. To create an account follow these steps:

When you have completed creating your account next you'll see the GitHub web interface.

The GitHub Web Interface

One of the ways you can interact with GitHub is through its web interface. The web interface allows you to manage all aspects of your GitHub account. When you first access the web interface it will look something like the following (Note: This is subject to change by GitHub. The examples below were captured in January 2022 of a new free plan account. If you choose to use a student plan or pro plan, the web interface is likely different.):

Next we'll take a look at a few common features of using GitHub and its web interface.


Creating a Repository

First let's create a new repository using the web interface. Since we're using the web interface, the repository will be created within GitHub. This will have no effect on my local computer, yet. Refer to the screen capture above, the first step is to click the Create Repository button. The Create a new repository screen will appear:

There are a number of options available when creating a repository. I will outline the key options you'll need to work with at first.

  1. The first field is the repository name. This will create a folder under your account's root named as you specify here.
  2. The Description field allows you to enter text that describes your repository. This is beneficial especially if you are going to make our repository public or share a private resository with others.
  3. The next decision to make is whether you want your repository public or private. If you set it to public, anyone on GitHub will have access to it, whereas Private will set it to be available only to you and anyone you explicitly invite to your repository.
  4. GitHub repositories generally have a readme file which is where you put a description and other information about the repository.
  5. When you are satisfied with your choices above, click the Create Repository button.

In the next screen capture below I have filled out the page with information for a sample project:

  1. I entered MyProject for the name of my repository.
  2. I entered a description for the repository.
  3. I set the repository to Private.
  4. I chose to include a Readme file.
  5. And I clicked Create Repository.

When the repository is created the new repository screen looks like this:

Notice the following details:

  1. The repository name was used to create a subfolder of my GitHub account.
  2. The Readme file was created and is a file now inside of my new repository folder.
  3. The repository name and the description I entered are the content of the Readme file. I can edit this file with the Pen icon that appears to the right of the Readme file name. Many repository Readme files contain details about the project, the contents of the project, instructions for how to use the contents of the project, etc.

If I click my GitHub name at the top left of the web interface it returns me to my main GitHub page:

Notice the following details:

  1. The Repositories tab now indicates that I have 1 repository.
  2. The Contributions Activity displays the first commit, that is, the new creation of the first repository. I can return to my repository by clicking its name in the Contributions Activity list.

If I now click the Repositories tab I'll see the Repositories page. As I create additional repositories this is a good tab to see them all together.

I can open any of my repositories from here as well by clicking its name.

We will explore more about the web interface below.


Creating a Repository Subfolder

If I need a new subfolder inside of a repository and I want to create that new folder in the web interface (there are other ways to do this outside of the web interface we'll explore on other pages of this eBook), it is not very intuitive how we go about it. There is no feature in the web interface to create an empty folder directly, but we can in a round-about way as follows:


To create a subfolder, we must create a file (odd, I know). GitHub will create a subfolder if we precede a file name with a subfolder name that does not yet exist. So, for example, let's say I want a subfolder called images where I plan to store image files. I can create the subfolder like this:

The readme.txt file is created as well as the images subfolder since it did not exist previously.

If I click on MyProject now, I'll see the contents of the repository which now includes the new subfolder:

While not very intuitive, it's easy to create new subfolders once you get the hang of it.


Uploading Files & Folders

Now that we have a repository there are a number of ways in which we can add files to it. For now, I'll show you how to add files with the web interface. You can find other approaches using external tools such as the GitHub Desktop software and other software tools that integrate with GitHub such as text editors, Integrated Development Environments (IDEs), etc.

Let's say I want to add a couple of image files to my repository and store them in the images subfolder created above. I'll use drag-n-drop with the web interface to add the files, like this:

We can repeat this process for any files, of any file type, we want to upload to our repository. As a reminder, here are the repeatable steps:


Cloning a Repository

Cloning a repository means to download a full copy of the repository to your local computer, which also maintains a connection to the remote repository. Cloning allows you to push changes to the remote repository on GitHub from your computer and also to pull changes to your computer from the remote repository that are made by others. Cloning from the web interface requires a tool on your computer's side in order to receive the cloned repository. There are many tools that can do this, like text editors, Integrated Development Environments (IDEs), GitHub Desktop, etc.


Downloading a Repository

Downloading a repository means to download a copy of the entire repository, however this is different from cloning (see above). While cloning maintains a connection to the remote repository from your computer so that you can push and pull changes, downloading does not maintain a connection. So, when you download, you are making a snapshot copy of the repository. You will not be made aware of any subsequent changes to the repository from anyone else.

To download a repository from the web interface do the following:


Downloading a Single File

Downloading a single file from a GitHub repository is different depending on the type of file you are trying to download. Sometimes this takes some experimentation to find the way to download it, but here are some tips for downloading files based on their file type.


Using Raw

Raw on GitHub is a way to open a text-based file (.txt, .c, .cpp, .java, .py, etc.) in its raw form. This is useful when you want to copy the contents of a text-based file. Here are some tips for using Raw:


Inviting a Collaborator

When you have created a private repository it is not available to anyone else. However, you can invite Collaborators. A collaborator will receive an invitation to join your repository so that they will have access to it. To inviate a collaborator for these steps:



From that point on that user can access the repository, push and pull to and from the repository, etc.


Deleting a Repository

To delete a repository follow these steps:


Creating a Personal Access Token (PAT)

GitHub uses Personal Access Tokens (PATs) in place of passwords for authentication with GitHub from external applications, such as IDEs, editors, etc. In order to use a PAT you must first create it through the GitHub web interface. The following instructions outline how to create a PAT for your GitHub account.

Note: You can find full GitHub documentation on PATs on GitHub's site here.







© 2023 John Gordon
Cascade Street Publishing, LLC