Git
2020-05-30 → 2026-08-17
An open-source distributed Version control system. It quickly became the most popular revision control system among developers. It is fast and has many advanced features. But, I think the popularity is largely thanks to GitHub, which is a web-based software development hosting system based on git. It is somewhat notorious for its unfriendliness1.
Related pages#
- GitHub — the most popular hosting service
- GitHub workflow — Some suggested workflows
- Cheatsheet
- Leaving Overleaf and Local LaTeX workflow — vs. overleaf
Learn#
Tutorials#
- https://gitimmersion.com/
- https://uvads.github.io/git-basics/
- Get started with Git in A List Apart
- https://learngitbranching.js.org — an interactive tutorial on git branching
- A Quick Introduction to Version Control with Git and GitHub in PLOS Comp. Biol.
- https://ohshitgit.com — what to type when you have already broken something
- Flight rules for git
- Aha! Moments When Learning Git — the conceptual model behind the commands
- The mighty reflog and the amazing bisect — two commands worth learning before you need them
Books#
Video#
- Git and GitHub for Poets by The Coding Train
- Tech Talk: Linus Torvalds on git at Google, by Linus Torvalds
- More git and GitHub secrets by Zach Holman
Recipes#
Everyday#
- How to Write a Git Commit Message
- System-wide gitignore:
git config --global core.excludesfile ~/.gitignore - Viewing all
git diffs with vimdiff - Using latexdiff with git
- https://www.smashingmagazine.com/make-life-easier-when-using-git/
- https://www.splitbrain.org/blog/2011-06/19-automate_github_pull_requests — scripting pull requests
Large files#
Git LFS and annex are the two primary tools; see How do Git LFS and git-annex differ? for the tradeoff.
Rewriting history#
Removing something from the working tree does not remove it from the history, which is why a committed dataset or key keeps haunting the repository.
- git-filter-repo — rewrite history quickly; the
git-filter-branchreplacement - BFG Repo-Cleaner — removes large or troublesome blobs, faster than
git-filter-branch - How can I remove/delete a large file from the commit history? on Stack Overflow
- gitignore doesn’t remove a file
Workflows#
The workflow that fits depends on the size of the team and how much git everyone knows; my own recommendation for a small research team is in GitHub workflow, and the simultaneous-editing case for manuscripts is in Local LaTeX workflow.
- A successful Git branching model — git-flow, the branching scheme everyone cites
- Why aren’t you using git-flow? — the counterargument
- Version control for solo Mac developers
Funny#
People who say “teaching is the best way to learn” have never experienced the seat-of-your-pants terror of trying to merge unrelated histories during an intro to Git workshop. - https://x.com/Hao_and_Y/status/1095494322059923456