- Backup your code
- Synchronize between laptop and HPC
- Git is an industry standard
- Collaborate with others
- Share your code
There are two protocols to use with git: https and ssh
# HTTPS git clone \ https://github.com/icbi-lab/current-topics-bioinformatics-lecture.git # ssh git clone \ git@github.com:icbi-lab/current-topics-bioinformatics-lecture.git
We recommend using ssh as it allows to set-up passwordless authentication.
Generate a ssh key-pair. It consists of a public and a private key.
# Generate a key-pair. Hit enter 3x to use # default settings and no additional password. ssh-keygen # display the public key cat ~/.ssh/id_rsa.pub
List remotes
git remote -v
Add a remote
# per convention, the default remote is called "origin" git remote add origin \ git@github.com:icbi-lab/current-topics-bioinformatics-lecture.git # but you can have other remotes as well git remote add my-fork \ git@github.com:grst/current-topics-bioinformatics-lecture.git
Push to a remote
# git push <remote> <branch> git push origin master git push my-fork master
Pull from a remote
git pull origin master
Set a default remote for current branch
git push -u origin master # now just use git pull/push without branch and remote git push
# create a tag git tag v0.1.0 # sync it with a remote git push --tags
The typical open-source collaboration workflow:
Example from nf-core/modules
:
Example from icbi-lab/scirpy
:
git push
The course website uses CI to automatically build slides from Rmarkdown documents. See