Whenever you make significant functional changes to your project, it is very useful to save your progress using git.
You can call the git commands from any place within your git repository (the top level directory contains a hidden
.gitdirectory). In this case, the repository is
MyAnalysis. Note that the path to the file(s) you in your git commands depends on where in the repo you are.
To view which files have been changed since your last commit, use the command:
This will show you a list of all of the files that have been modified or deleted as well as files that are not yet known to the repository.
If you see a large number of files that you do not want to commit to the repository, such as temporary files, binary files, or log files, you can create a file called
.gitignorein which you define file names or patterns with wildcards (
*) that will be ignored by
.gitignorefor it to take effect.
It is generally good practice to check the changes to a file before committing it. Do this with the command:
git diff <filename>
<filename> should include the relative path to the file from the
When you have confirmed that the changes in the file are good, stage the file to be committed using:
git add <filename>
You can also remove a file from the repository or commit the deletion of a file using:
git rm <filename>
After staging files, you can double check the changes you have staged to commit using:
git diff --staged
Next, commit the staged changes using:
git commit command will open a text editor for you to add a commit
message describing the changes. This is an important step so you can keep
track of the changes you make.
By default, git will use your default editor as defined by the environment variables
EDITOR. If neither is defined, it will use
vim. You can change the editor for git using, e.g.,
git config --global core.editor nano.
Finally, push your changes to the remote repository using:
You may need to specify the remote repository and the remote branch if you are working on a new local branch or want to push the changes to a different remote repository than the one you cloned from. This is done with
git push <remote-name> <branch-name>.