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:
git clone
the repository to your local computer.- edit the files (like jupyter notebooks)
git add
the changed files to the staging areagit commit
changes in the staging area to the history(not sure about this word)- (optional)
git push
the changes to the remote repository (Github) - 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
- https://www.atlassian.com/git/tutorials
- The
man
pages of the git commands