Introduction to git
- Version control is like an unlimited ‘undo’.
- Version control also allows many people to work in parallel.
- There are multiple online repositories for storing projects that all
use the underlying Git framework
- Bitbucket is one such service, using Git to provide functionality to
collaborate with other people
- We can browse the history of the contents of repositories and see
who made which changes
- Other platforms like Github look different by employ the same
fundamentals
- git configuration is all stored in
~/.gitconfig
- The config is specific to each computer you use.
- Initializing a Git repository is simple:
git init
- Commits should be used to tell a story.
- Git uses the .git folder to store the snapshots.
- Git history can be reverted without modifying it
- Once changes are committed they are safe
- Changes that are not committed can be deleted
- A branch is a division unit of work, to be merged with other units
of work.
- A tag is a pointer to a moment in the history of a project.
- Conflicts usually appear because of not enough communication or not
optimal branching strategy.
- A repository can have one or multiple remotes
- A remote serves as a full backup of your work.
-
git push
sends local changes to the remote
-
git pull
gets remote changes onto your local
machine.
- A remote allows other people to collaborate with you
- Sharing a repository needs good communication.
- Branches are really necessary.
- Pull requests enable sensible merging of changes between branches
and across repositories.
- Git tags may be generated to note a particular version in
history.
- Consider use of git early in scientific workflows, for robust
documentation.
- Open scientific work is more useful and more highly cited than
closed.
- Make use of .gitignore to list files to exclude.
- Don’t commit sensitive, personal or machine-specific
information.
- Don’t commit large data files.
- Git works best with text files, for which it can track individual
line changes.