Git
Why to use git - decentralized version control system(VCS)?
- Reproducibility (VCS)
- Collaboration (decentralized)
Bonus features:
- Log of changes (git log and commit messages)
- Tracking issues (not native to git, but many systems exist)
git != github
Original author: Linus Torvalds
The git referred to in git clone, etc. is not connected to github, but to the Linux development community (and in particular Linus Torvalds, the creator of Linux), i.e. open source software.
github: web interface to interact with git, bought by microsoft, free cloud hosting, like free email
Alternatives:
Advantages of frontend
- Issues
- Wiki
- Projects
- Pull Requests
Commands
Most used commands:
git clone: Get code from internetgit init: Start new projectgit add .: Stage all changesgit commit -m "": Commit changesgit status: Check status of VCSgit push: Copy to remotegit pull: Copy from remotegit checkout: Change versiongit branch -n: Create new version
Complicated commands:
git mergegit rebase
Underused commands (need some scripts to make them useful):
git log: Confirm graph for rebase/mergegit diff -- FILE: Time travel to check history of filegit checkout --patch, split: Interactively apply changes
Hygiene
- Use code autoformatting.
- Write tests for basic setups like testing paths.
- Do not push to the
mainbranch, use your own branch to make changes, then issue PR to merge those changes tomain. - Mark commits that have been tested with some prefix (e.g.
YES:...), or (e.g.BUG:...) for those that dont pass tests. - Save git commit hash with experiment runs, including info if it is dirty or clean.
- Reflect changes to data by keeping a changelog that matches commits.
Resources
GUI:
For VSCode:
To see examples of commands:
Cheatsheets:
Tutorials:
Workflows:
Official documentation: