Ideal: You want research to be portable and reproducible
portable: e.g., you want to work on the same code on different computers
reproducible: you want to be able to return to your code in 6 months, pass your code to someone else and have it work for them, etc.
Central concept: a repository. A repository is a collection of linked snapshots of files that together describe the complete history of changes.
Create repository on github.com
From terminal (ideally within a 'repositories' directory), enter command:
$ git clone https://github.com/<github user name>/<repo name>.git
This copies the repo from github.com to my computer.
Edited some file(s), save changes to local computer.
If I create a new file on my computer and want git to track it, I have to add it to the repository:
$ git add filename.py
Commit those changes to local repository:
$ git commit -am 'something interesting'
Now, sync back to github:
$ git push
At any point, we can check the status of the repository (see what files have changed, if there are untracked files, etc.) by entering:
$ git status
Whenever you start working (for a particular work session) on a computer, have the first command you do within the repository folder be git pull.
Complementarily, when you stop working for a session, make sure you git push.
git is complaining that it doesn't know who you are: listen to it in order to change the email/name that it assigns to you.
Running some git command pops up a mysterious text-editor window that you can't get out of. This most likely is vim or vi, a command-line text editor. It's most likely asking you to confirm a default commit message. You need to save the open file and quit the editor---you do this by typing :wq and then pressing enter (this stands for "write/quit").
Merge conflict! If you get a message that says CONFLICT, then you can open the files that are conflicted, and pick which version you want (remove the >>>>>>> and =======, etc. lines)
Doesn't let you push, with some error like "rejected!" "failed to push some refs" etc. What this means is that you have some changes remotely that you haven't yet pulled locally. Do a git pull (you will probably have to deal with vim at this stage (point 2.) and then git push again.
In [ ]: