7 ms·
I won't comment on Mercurial because I don't know anything about it. I really do feel like Git is appropriate for small projects. The .git store is incredibly
by Someone1234 12y ago
I won't comment on Mercurial because I don't know anything about it.
I really do feel like Git is appropriate for small projects. The .git store is incredibly small (because it only stores changes) and quite simple when you get used to it. You will only only need to use a tiny subset of Git's functionality (or, heck, just the Github web-UI if you wish).
I think the hardest thing about Git for big and small teams is getting used to the mental model of Git (branching, merging, master, etc). Once you get it down you realise that Git is less complex, not more...
PS - This comment is mostly in reply to the implication that Git is a better tool for large and complex projects like the Linux Kernel.
PPS - Mercurial might be a better tool yet still for small projects, I don't know enough about Mercurial to have a qualified opinion either way.
- acveilleux 12y agoFor all intent and purpose, git and hg are fairly equivalent. In day to day usage, the two big differences are: 1. Local branches Git has them, mercurial doesn't really. Mercurial wants you to use a lightweight clone (copy-on-write with hard links) instead. Lots of mercurial extensions deal with this however. The lack of rebase in stock hg is probably directly driven by the lack of local branches that don't get pushed upstream by default. 2. Committing code Mercurial, without extensions, doesn't have the git shelf. With extensions there's a few competing options like MQ, Shelve or Evolve. Both these points make hg easier to learn (branch == clone is very easy to wrap your head around, commit behaves basically like svn/cvs).
- ngoldbaum 12y agoFor several years now Mercurial has had bookmarks in core, which are analogous to git's local branches. It's also worth pointing out that many of the extensions you referred to (rebase, shelve) are bundled with core Mercurial and need only a one-line addition to a configuration file to turn them on. Extensions bundled with core Mercurial have the same level support and backward compatibility guarantees as the rest of Mercurial. Part of Mercurial's command line philosophy is to not include obvious foot-guns (like the ability to rewrite history) in the default version.
- imakesnowflakes 12y ago>Mercurial wants you to use a lightweight clone.... You can make a named branch and make it private so that it wont be pushed automatically or you can create a bookmark and mark the changeset as private, so that it wont get pushed automatically OR you can create a local clone, completely isolated from the origin repo. The difference between git branches and Mercurial branches is a bit of a conceptual one. Git has 'user' branches, where a branch corresponds to the work of a user. Mercurial has 'feature' branches, where each named branch (is supposed to) correspond to a feature. I think This is the one of the reasons some Git users are sometimes so turned off when they see Mercurial branching model. And to me, I would like a project as a sum of its feature branches. But I can imagine why this might not be optimal for a something like Linux kernel. But for most projects, I think feature branches are more valuable than the user branchs of git. >Mercurial, without extensions, doesn't have the git shelf. Shelve extension is bundled, enabling is just a matter of turning on a flag in the .hgrc configuration file...
- stormbrew 12y ago> Git has 'user' branches, where a branch corresponds to the work of a user. Er. Not really, no. Git is simply agnostic about how you use branches, and allows you to separate how published branches and your local branches are used implicitly. I've rarely worked on a multi-user git project where published branches corresponded to a user's work. Almost always they are feature branches worked on alone or with someone else. Even in linux development, where the repositories are directly tied to users usually, the actual branches generally represent a work-unit of some sort, so I'm not sure where you got this idea.
- acveilleux 12y agoIt's probably pervasive because of github and pull requests where, at least for open-source projects and external contributors, it's true in practice though not enforced.
- stormbrew 12y agoI'm confused as to what "it" means here? If you mean the idea in the GGP's post that branches represent a user's work, again I think that conflates repositories with branches. It's not exactly impossible to find people doing work on master of their fork against an OSS project, but best practices (and common practice among most regular contributors I've seen) seem to angle towards using feature branches even then (and asking with a PR to merge eg. stormbrew/blah:fix-the-thing to upstream/blah:master).
- rbehrends 12y ago> 1. Local branches Local branches are really an artifact of Git having a garbage collector. That means that any commit that you want to keep must be attached to a branch so that it may not be inadvertently lost. Without a garbage collector, that is not necessary. In particular, in many other VCSs, you just simply commit without having to create a branch in the first place. Labeling them (via whichever mechanisms your VCS provides) is typically optional with modern version control systems. You can argue that you prefer having a garbage collector over having to explicitly delete commits/branches that you do not want any longer, but that would be a different issue. > 2. Mercurial, without extensions, doesn't have the git shelf. This is sort of incorrect -- or rather, probably a misunderstanding. Shelve is part of standard Mercurial and has been for a while (same goes for MQ). While it is disabled by default and enabled in the extensions section, it's no more an extension in any meaningful sense of the word than git stash (which technically calls out to a shell script [1]). Mercurial's shelf is a python module [2] that is loaded when you flip a switch. > Both these points make hg easier to learn (branch == clone is very easy to wrap your head around, commit behaves basically like svn/cvs). This is really more a feature of Bazaar, not Mercurial. [1] https://github.com/git/git/blob/master/git-stash.sh https://github.com/git/git/blob/master/git-stash.sh [2] http://selenic.com/repo/hg-stable/file/default/hgext/shelve.py http://selenic.com/repo/hg-stable/file/default/hgext/shelve....
- saraid216 12y ago> In particular, in many other VCSs, you just simply commit without having to create a branch in the first place. Labeling them (via whichever mechanisms your VCS provides) is typically optional with modern version control systems. Since, for me, local branches are a massive part of why I prefer git, I'd be interested in examples of how to do the same thing in other VCSs. It doesn't make sense to me that they're a byproduct of having a garbage collector, since (1) git-stash exists, (2) local branches are a common selling point, and (3) git-clean honestly seems tacked on rather than a core piece of the design.
- Blackthorn 12y agoFor Mercurial, you create a new local branch by committing at a point that's not a tip (or not HEAD, if there's just a single branch). By default, it doesn't have a special name (like a git branch does). You can give it a name via "hg bookmark". The feature set is honestly fairly similar, it's just different in the way it is presented. In git you go into a "detached HEAD" and have to explicitly name a branch or commits will get lost. In hg you commit and it creates a new tip, but it doesn't have a name unless you explicitly name it via bookmark.
- LukeShu 12y ago> The .git store is incredibly small (because it only > stores changes) git stores a complete copy of each revision, not changesets. (Well, it is my understanding that a .pack compressed archive of objects may store some of the objects as changesets, but that's not the general case)
- stormbrew 12y agoWhen git repacks[1], which it does periodically (but not on every commit), it will store objects in as compact a form that it can, which basically means that it looks for root objects that it can delta a given object against so it stores each chunk of text as few times as possible. What it doesn't do is store files as deltas explicitly against the previous or next revision of that file. It attempts to find a best fit dynamically. It also does something like this packing procedure when responding to a fetch to avoid sending more data than it needs to, btw. [1] https://www.kernel.org/pub/software/scm/git/docs/git-repack.html https://www.kernel.org/pub/software/scm/git/docs/git-repack....
- Someone1234 12y agoIt stores a complete copy of the file, not a complete copy of the entire repository. So it keeps your .git fairly light weight since only changed files have duplicate copies. Essentially it is not line level, but file level, rather than complete repository level (e.g. like Team Foundation is).
- josteink 12y ago> So it keeps your .git fairly light weight (... compared to ...) Team Foundation And you can tell from how the product is being used. Where I work, we use TFS and you literally need to have committee meetings before a new branch is made. You need to agree on long term strategies, you need to agree on branch hierarchy (because TFS cannot merge without one), you need to replicate all-the-things(tm) for your new branch, you need to adjust your versioning-strategy for this branch, and possibly future branches which may come and may not ever collide with this one, because TFS branches are massive and carved in stone. They are forever. Etc etc. You never branch more than once a year. In the world of TFS, doing such would be madness, haphazard. Or at least you would need a full team doing nothing but branching and merging and integration. And good luck trying to find qualified people willing to have that as their day-job. With git you branch every single time it makes sense, usually several times a day. And your life is nicer because of it. It's funny how such technical decisions results in such huge and enormous visible changes to how a product is being used. Somewhere deep in Microsoft there are probably one or more engineers crying right now seeing the effects of their (back then) seemingly innocent decision, as they themselves are forced to deal with TFS in their daily work and they see how nice the gitters have it.
- Aga 12y agoFor me Git has also worked very well for small projects. I actually learned it initially by using it for my masters thesis. One correction: Git does not store changes at all. It stores all the versions of files as separate "blobs". What keeps .git small, is that Git compresses the object database to pack-files. "git gc" does this for you. Pro Git has a great chapter about how Gits internals work: https://git-scm.herokuapp.com/book/en/v2/Git-Internals-Plumbing-and-Porcelain https://git-scm.herokuapp.com/book/en/v2/Git-Internals-Plumb... This picture sums the model nicely: https://git-scm.herokuapp.com/book/en/v2/book/10-git-internals/images/data-model-4.png https://git-scm.herokuapp.com/book/en/v2/book/10-git-interna... For me studying Git internals has been a good lesson in software design. Git's core is very simple, yet somehow that makes it a really versatile tool.
- jebblue 12y agoGit rocks for small to medium sized projects, never tried it on a large one but Linus made it for the kernel so that would not worry me either. Going into a directory and easily creating a repo there, where I need it, is great. Canonical did something similar with their Bazaar tool.