1
0
This repository has been archived on 2025-03-06. You can view files and clone it, but cannot push or open issues or pull requests.
ResearchMethods/tutorials/git_and_github.md
2018-04-30 14:51:28 +10:00

1.8 KiB

Git and Github

Git is a version control system that tracks the line-by-line chages to a project in a repository and Github is a website that hosts these git repositories.

This tutorial should cover the basics of working with Git and Github.

Common Workflow

The common git workflow is as follows:

  1. git clone the repository to your local computer.
  2. edit the files (like jupyter notebooks)
  3. git add the changed files to the staging area
  4. git commit changes in the staging area to the history(not sure about this word)
  5. (optional) git push the changes to the remote repository (Github)
  6. go to step 2.

Note: git status can be really useful for seeing what the current state of your repository

Step 1. We want to get the repository from Github onto our computer, so that we can make our own changes to the project. To do so, run

$ git clone https://github.com/Dekker1/ResearchMethods.git

from whatever directory you'd like to work from.

Step 2. pretty self explanatory here

Step 3. Git uses a staging area to house the changes before committing the changes to the history (much like how you can save the changes to an assignment submission on Moodle without submitting the assignment). Say we've been editing a file, foo.ipynb. Use

$ git add foo.ipynb

to add these changes to the staging area.

Step 4. In order to finalise changes, use

$ git commit

and don't forget to write a nice message about the changes made.

Step 5. In this step we pull the changes from the remote repository and merge them with ours. Then we push the merged changes back up to the master branch of the origin (the remote repository).

$ git pull origin
$ git push origin master

Step 6. also self explanatory

More Information