I like the view on git's buckets here: https://ndpsoftware.com/git-cheatsheet.html
And linked to by that same site, How to get out of a mess: https://web.archive.org/web/20230328075555/http://justinhileman.info/article/git-pretty/git-pretty.png
My long-winded presentation with lots of whiteboard drawings is:
Git = a time-machine + interdimensional teleporter
History of version control
- Locking of files: CSV, only one person per file
- Centralized serial versions: SVN, multiple people per file, but must share files using a central server
- Distributed social version control: Git, anyone can work anywhere, even a desert island with no internet for years and still contribute and work together.
Learn the vocab for git and the bucket concepts and which bucket you are using (see git-cheatsheet link above, and hover over items after clicking)
- Stash, like a pile of clipboards, no history, just a scratch space to put some temp changes
- Workspace, Windows File Explorer, the present state of the files on the computer
- Index, “Staged” changes, changes that are going to be pushed into the local repo
- Local Repository, the history of snapshots and commits saved to the .git hidden folder at the root of your source folder
- Upstream Repository, the shared .git folder out on a server, e.g. github.com/my-co/my-repo.git or git.advise-conning.com/ADVISE
Note that the verb’s for git are independent of the interface (SourceTree v CLI etc).
- SourceTree uses slightly modified phrases for some verbs, but if you know the verbs the SourceTree interface is more intuitive. Also the internet documents the git verbs well and doesn’t document SourceTree’s phrases super well.
- Downloading and installing and checking out the first repo with credentials with SourceTree is non-trivial. Take some time to help new people do this.
For viewers: pull
, fetch
, reset
, checkout
Learn how to look at the history of a single file, or jump back in time to a commit, and return again
What HEADLESS means (not at a tip of a branch and therefore cannot do a commit until a new branch is made).
What a Pull Request is.
The difference between Git, GitHub, GitLab, BitBucket, and SourceTree
Merging pulls changes from someone else’s branch TO your current branch. (e.g. checkout feature/my-task, then merge release/2.3 into feature/my-task)
revert
is not what you think it is. reset
is usually what you want. reset –-hard
is destructive, but great for fixing a mess or getting rid of a bad commit. See How to get out of a mess link)
Then there is git-flow, and we use a modified version of it, but the core concepts are still relevant:
https://nvie.com/posts/a-successful-git-branching-model/
https://github.com/petervanderdoes/gitflow-avh (Tooling around git flow)