4 ms·
As also "that guy that people go to for git help", I've seen people clearly surprised that: - cherry-pick creates "duplicated" commits - you can checkout a co
by seba_dos1 3y ago
As also "that guy that people go to for git help", I've seen people clearly surprised that:
- cherry-pick creates "duplicated" commits
- you can checkout a commit, rather than a branch
- two commits in the same repo may be topologically unrelated to each other
- merge commit can contain changes unrelated to its parents (usually after making some by accident)
- you can git reset --soft
Those are just the ones that came to my head on a whim (and don't get me started on rebase-heavy workflows). I've had people telling me that it "finally clicked" when made aware that commit is a state rather than a change. Explaining what I just did to "fix" someone's repo is also often easier after a proper "commit as a snapshot" prelude. If people who used Git for years say "oh, that makes much more sense now" after being presented with basic Git concepts, it suggests that their mental model may have been somewhat flawed.
Once you internalize that commit is a snapshot, going from that to thinking about diffs between two commits is easy. The other way around is not so obvious - when checking out a commit from complicated topology, it may not be immediately clear how to get from one state to another by "applying diffs" even if it's technically equivalent, so simple operations will end up seeming like undecipherable magic to you simply because they don't fit your mental model very well.
- tomn 3y agoI don't see any of those things as working differently in a diff-based SCM, sorry. If those things conflict with someone's model, then that model is more/differently wrong, and not the one that i'm talking about, which is equivalent to how it actually works.
- seba_dos1 3y agoWe're talking about models used by novice people to learn and understand Git, not about theoretical equivalency of mathematical graph transformations - the latter is a truism and doesn't bring much to the table, while the former will obviously be more or less flawed for a while until you become more experienced and fill in the gaps. People who may even have no familiarity with graph theory don't gain anything from thinking about commits as diffs in Git. The whole thread started with a notion of "particle-wave duality", which is technically true, but useless in practice when "diff between two arbitrary commits" is one of the simplest operations to think about in terms of graphs of snapshots.