A lot of people are confused by git. Most of these people, I reckon, learned it from the outside in - from the command-line interface down. If you started with git by asking "how do I sync up my changes with my peers", then you might get the answer, but you will be missing the foundation on which that answer is built. This is the main source of confusion with git.

The better way is to learn git from the inside out. You should first learn about what objects are and how they're stored and identified, and how they relate to each other. You should learn what blobs, trees, and commits actually are, and how they relate to each other, and how commits form a linked list from which a graph of all objects can be derived.

Then you should learn how the ref database gives friendly names like "master" and "feature/foobar" to objects, and how the reflog tracks changes to references over time.

THEN, and only then, should you learn how to use the CLI. Then you can learn about using the staging area to add objects to the database and create commits, and how doing this updates the reflog.

Git makes total sense when you approach it from this angle. Supposedly hard tools like git rebase are totally understandable when you view them with the appropriate foundational knowledge.

Git is a tool which you will reach for hundreds of times a day, every day, for your entire career. Maybe it's worth learning about properly.

@sir I haven't had problems with git, but people get confused by inconsistent command lines. For example, checkout means switching branches or using a file. There are also ambiguities around checking out a branch by name, SHA1, or filename.

@farhan checkout makes sense when you understand it incontext. Switching branches and "using" a file (what does that mean? Do you mean resetting a file?) are the same fundamental process in git. Again, you're looking from the outside in when you should be looking from the inside out.


@sir @farhan `checkout` does seem…inconsistent? weird, to me. `git checkout $branch` changes HEAD, but `git checkout $commit_ish $path` doesn't. I think `switch` for the former and `restore` for the latter make more sense.

@moonbolt @farhan changes HEAD, and then checks out everything to make the world consistent.

Sign in to participate in the conversation
Interlinked MST3K

this is mst3k