3 ms·
>...So, you don't "remove (or add) a commit from a branch", you change where a branch point to. Well, once committed, the corresponding deltas to parent are pa
by zoomablemind 4y ago
>...So, you don't "remove (or add) a commit from a branch", you change where a branch point to.
Well, once committed, the corresponding deltas to parent are part of the branch (that is a node of the branch graph). Thus, if user wants to have this commit in a different graph, then the deltas need to be regenerated and recommitted (then deleted from the wrong graph).
As for the branch name, in Git it's just a label for the graph leaf. However, some SCMs maintain branch name for all constituing nodes in the branch graph.
- elsjaako 4y agoIf you are talking about the thing that git calls a branch, it's literally just a pointer to a commit. You can look it up manually. Here is a random repo I have on my PC: ~/p/s/sigrok-cli> cat .git/refs/heads/master 7bdc46d6fcdcfa00dd29ac102f3128aeb44a479c In principle all these objects are in the .git/objects folder. But the encoding is some binary thing for branches, and anyway it's often stored differently (I assume for space saving reasons). But git can explain what every object is. ~/p/s/sigrok-cli> git cat-file -p 7bdc46d6fcdcfa00dd29ac102f3128aeb44a479c tree fa02da4030e5791695b8a7a5400ee2c2cc88ee46 parent 09fc39da486b8618d65b66ca96a760478c3e89e2 author Uwe Hermann <...> 1454100673 +0100 committer Uwe Hermann <...> 1454100673 +0100 NEWS: Update for upcoming 0.6.0 release. ~/p/s/sigrok-cli> git cat-file -p fa02da4030e5791695b8a7a5400ee2c2cc88ee46 100644 blob d1d8ffca429d2a4697a56fd7dedbeee3fc6d577d .gitignore 100644 blob 28c1b20e6d7d146fbc6ad0270ff5b09cfd057b26 AUTHORS 100644 blob 94a9ed024d3859793618152ea559a168bbcbb5e2 COPYING 100644 blob 04c29abe3dc42c8ecb8ec1b71093437d8c382ebd HACKING 100644 blob c6d6c8a7cff1a5b7d940e0c040ad1d4f5337f646 Makefile.am ... etc The git software just updates the branch to create the illusion that it's not just a pointer to a commit. But really, it's literally a file with the sha1 hash of the commit.
- Dylan16807 4y agoWhat deltas? Commits are full snapshots. The only time deltas come into play are in pack files, and those store objects in completely arbitrary order.
- motoboi 4y ago> Well, once committed, the corresponding deltas to parent are part of the branch (that is a node of the branch graph). Not sure what you mean by deltas here, but if you are taking about changes, git don’t store changes, each commit references the state (the content) of the whole repository. The diffs are just a representation calculated to you. Like: `git show <commit B>` shows a diff, but actually what happens is that git calculates the difference between all repository’s files as they were (their contents) in commit A vs their contents in commit B. Git does that in a very efficient way, but commit are actually snapshots.