1
0

Added tutorial for the git workflow.

This commit is contained in:
Kelvin Davis 2018-04-28 21:11:32 +10:00
parent 2028742bef
commit 8025c14b52

View File

@ -0,0 +1,52 @@
# 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 remote
$ git push origin master
```
**Step 6.** *also self explanatory*
## More Information
- https://www.atlassian.com/git/tutorials
- The `man` pages of the git commands