Version control
Git as journaled backup
When you are in your <repositoryname>
folder, you can run git commands to manage your files, record their changes and sync them to the repository on GitHub for safe keeping. These tutorials are good introductions to git.
To journal the creation or modification of a file, you need to add
it to git:
Terminal
git add <the_changed_file>
This “stages” the change. This adds the file to the a “group” of changes that represent some modification to your project. You can add more files to that “group” by running the command again with other files. If you run git status
you can see that the files are now staged.
So maybe you added or changed two python files addressing some parcitular problem or advancing some part of your project. Now you want to store those of changes to the journal maintained by Git and associate it with a short message describing the changes. For that you use:
Terminal
git commit -m '<message>'
If you added two python files, your description could be 'Added two python files for my analysis'
. If you fixed a bug or added new code to the files, your message should reflect that.
Now your changes are recorded in the version of the <repositoryname>
on the cluster, but that does not serve as a backup in case you accidentally delete your entire folder or the cluster burns down. To backup your repository you need to synchronize your local <repositoryname>
repository on the cluster with the <repositoryname>
repository on GitHub. To du that use:
Terminal
git push
In addition to keeping your precious files safe and backed up, your GitHub repository also serve as a journal documenting of your progress. Each commit is a snapshot if your project that can be retrieved at any time.
Git
There is a cheat sheet here and some good visual guides here and here.
The three most important commands to learn are: git status, git add, git rm, git mv, git commit and git push.