3 ms·
Git doesn't really have changesets as first order objects; it has snapshots. Each commit is the hash of a snapshot of the tree at that point, together with the
by rlpb 16y ago
Git doesn't really have changesets as first order objects; it has snapshots. Each commit is the hash of a snapshot of the tree at that point, together with the commit message and the hash of any (at least one) parent commits. This is pretty much the entire data model. The rest just pops out, which is why it is so elegant.
- tzs 16y agoMinor correction: there does not have to be at least one parent commit. A commit can have no parent. The root commit, for example, should be parentless. A repository can have more than root. For instance, I have a repository that was formed from merging two separate repositories. From a code history point of view, the two repositories are unrelated, so in the merged repository each has its own root.
- psadauskas 16y agoGithub also takes advantage of this; if you make an empty branch called "gh-pages", and put static html (and css, js) in it, Github will host them for you. I've also used it to greenfield some ideas in the same project. Its a bit of a hack to create one, though: git symbolic-ref HEAD refs/heads/newbranch rm .git/index git clean -fdx <do work> git add your files git commit -m 'Initial commit' (From http://book.git-scm.com/5_creating_new_empty_branches.html http://book.git-scm.com/5_creating_new_empty_branches.html)
- davvid 16y agoThe community git book will often do things "the old fashioned way" to keep compatibility with older versions of git. Modern versions of git let you do this instead: git checkout --orphan new-branch