Added tutorial for the git workflow.
This commit is contained in:
parent
2028742bef
commit
8025c14b52
52
tutorials/git_and_github.md
Normal file
52
tutorials/git_and_github.md
Normal 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
|
Reference in New Issue
Block a user