Skip to Main Content

GitHub: Home

Beginners guide to using GitHub.

What is GitHub?

What is GitHub?

"GitHub is a cloud-based platform where you can store, share, and work together with others to write code."

 

Get GitHub

Creating a Free Account

If you are running into issues you can go here.

You can also try out the "Hello World" tutorial.

Get GitHub Desktop

Download GitHub Desktop

If you are running into issues you can go here.

Research Engagement and Data Curator

Explanation

Dashboard

 

New Repository

There are two ways to create a new repository: by clicking the new button on the dashboard in the website, or by clicking File à New Repository (or Ctrl+N) in GitHub Desktop.

Website: Fill out the information that it requires and the repository will be created.  The repository will be created in your remote repository.   

GitHub Desktop: In GitHub Desktop the repository will be created in the designated folder of your choosing.  When you create, add, delete, or change files in this folder on your computer, GitHub Desktop will recognize a change has been made and will ask if the changes should be committed.  The changes will not be reflected until you Commit and Push the information back to the GitHub website.  Then the changes can be seen in your account on the website/remote version.

 

Add a file

Website

To add a file directly on the GitHub website:

  1. Navigate to one of your existing repositories or create a new one.
  2. Click on the "Add file" button.
  3. Choose one of the following options:
    • Create new file: This will open up a text editor where you can create a new file. Ensure to save it with the appropriate extension in its name.
    • Upload files: This allows you to upload files from your local machine to the repository.
  4. Remember that any file added via the website is saved directly to the remote repository. You will need to fetch/merge or pull these changes to your local directory to keep it up to date.

GitHub Desktop

To add a file using GitHub Desktop:

  1. Ensure the local repository is created on your computer.
  2. Save or move the desired files into the repository folder.

 

Commit a file

Website

  1. After creating or uploading a file, click on "Commit changes" (green button).
  2. Enter a commit message that describes the changes made.
  3. Choose to commit directly to the main branch or create a new branch for the commit.
  4. Click "Commit changes".

GitHub Desktop

  1. Open GitHub Desktop and navigate to your repository.  GitHub Desktop automatically keeps track of all the changes you make.  When you open it and go to the desired repository you are working on, it will show a list of changes that you have made.
  2. Ensure the file you want to commit is saved in the repository folder.
  3. In the "Changes" tab, you should see the file listed.
  4. Add a summary and a description for the commit.
  5. Click "Commit to main" (or the current branch).

Push

Website

You don’t have to push the changes from the website because you are already in the remote repository.   Push means putting files/changes from the local to remote repository.

GitHub Desktop

After you commit the changes you make, click “Push origin” so that the changes are pushed to the remote repository. 

Fetch & Merge

Website

You can’t fetch anything from the website because fetch means grabbing files/changes from the remote repository and putting them in the local repository.

GitHub Desktop

  1. Click on "Fetch origin" to retrieve the latest changes from the remote repository.
  2. If there are new changes, GitHub Desktop will prompt you to "Merge" those changes into your local branch.

Pull

Website

The “Pull” request is for taking things from the remote repository and putting it in the local directory, so this cannot be done on the website.

GitHub Desktop

Clink on “Pull origin” to fetch and automatically merge changes from the remote repository to your local repository.

Branching

Branching is a fundamental concept in Git that allows you to diverge from the main line of development and continue to work without affecting that main line. Branches provide an isolated environment for your work, enabling you to work on features, fixes, or experiments independently.

Create a Branch

Website

  1. Go to your repository page on GitHub.  Click on “Branch: main” dropdown.
    • Note: makes sure you are on the branch you want to branch from.
  2. Type the name of your new branch in what looks like a search bar.  If the name is new, it will prompt you to click on create the new branch.
  3. To switch the branches, click on the “Branch: main” dropdownand click on the branch you want.

GitHub Desktop

  1. Go to your repository you want to work on.  Click on “Branch” dropdown.
  2. Click on new branch and enter the name of your new branch. Click on what branch you want to branch from.
  3.  To switch the branches, click on the “Branch” dropdownand click on the branch you want.

Note: Your local directory will change depending on what branch you are working on.  So make sure the branch you want is selected in GitHub Desktop

Merge a Branch

Website

  1. Click on pull requests.
  2. Click on Compare and Pull.
  3. Enter information about the pull request/merge.
  4. If there are no conflicts, click Merge pull request and confirm merge.

GitHub Desktop

  1. Make sure you are on the branch you want to accept the merger.
  2. Click on Branch from the top menu bar.  Then click on Merge into current branch.
  3. Choose the branch to merge into the current branch.
  4. Remember to push the changes to your remote repository, by clicking push.

Note: Sometimes a merging a branch will not work because there is a conflict in a file. This needs to be rectified before completing the merger.

Get Previous Version

Website

  1. Go to the repository page.
  2. Click on the button that shows how many commits there have been.
  3. You can view the repository at each different commit.

GitHub Desktop

  1. Click on History
  2. Choose the commit you want to revert.  You should revert in order from newest to oldest till you get to the one you want to revert.

Gitignore File

The gitignore file is a useful file that will tell GitHub Desktop which files not to upload into the remote repository.  For example, large or confidential files will be ignored when you push your repository.  The gitignore file is just a text file with the list of file names to ignore.  You can also put a star(*) in front of an extension and it will know to ignore all files of that extension type.  For example, *.csv will ignore all .csv files regardless of the name of the files.

Search and Fork a Public Repository 

GitHub is home to many public repositories that you can use for your own work (double check licensing agreements for anything you do want to use in research/publications).  You can make a copy of these public repositories by clicking on the Fork button.  This will create a new repository under your account with all the files from the repository that you wanted.

GitHub Help Documents

If you nee more instruction you can go here: GitHub Docs