Size: 5223
Comment:
|
Size: 324
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
= Mercurial for Git users = ---- /!\ '''''UNFINISHED, PLEASE DO NOT LINK YET''''' ---- [http://git-scm.com Git] is a very popular DistributedSCM that works very similarly to Mercurial. However, there are some conceptual differences that may puzzle the casual Git user when using Mercurial. [[TableOfContents]] == Logical architecture == In general, Git's feature set is the largest among all [:DistributedSCM:DVCS] software, but Mercurial can equally cover a great extent of it. === History model === Mercurial's view of history is, just like git's, a [:UnderstandingMercurial:DAG] or Directed Acyclic Graph of commits. The difference is that, in Mercurial, ''commits'' are called ''changesets'', a rough approximation of the ''tree'' git concept is the ''manifest'' and there is no notion of ''blobs'' because Mercurial refers directly to files. Aside from that, the graphical representation of history is the same in both cases. They both use the SHA1 result value to identify commits/changesets. Additionally, Mercurial also provides a '''local''' ascending number for each revision instead of providing the reverse count notation provided by git (for example, HEAD~4). === Branch model === Also like in git, Mercurial supports branching in different ways. First and foremost, each clone of a repository represents a branch; eventually identical to other clones of the same repositories. This way of branching sometimes referred as ''heavy branches'' and it works the same for both systems, although the way is handled differs slightly due to git's notion remote branches; more on this later. Then git has its famous ''lightweight branches'', which allow to switch between development lines within the same clone of a repository. Take the following history graph as an example: {{{#!dot digraph { label = "Light branches example"; rankdir = LR; node [shape=box]; a -> b -> c [dir=back]; c -> d -> e [dir=back]; c -> f -> g [dir=back]; e -> X [dir=back, style=dotted]; g -> Y [dir=back, style=dotted]; X [shape=plaintext]; Y [shape=plaintext]; } }}} In git, branches `X` and `Y` are simply references to the `e` and `g` commits. If a new commit is appended to {{{e}}} then the reference `X` would then point to such commit, like so: {{{#!dot digraph { label = "Moving reference example"; rankdir = LR; node [shape=box]; a -> b -> c [dir=back]; c -> d -> e -> h [dir=back]; c -> f -> g [dir=back]; h -> X [dir=back, style=dotted]; g -> Y [dir=back, style=dotted]; X [shape=plaintext]; Y [shape=plaintext]; } }}} Mercurial has '''always''' supported these kind of branches, but with a different name and somehow in an anonymous way. In Hg, the `X` and `Y` branches are called ''heads'' and, until recently, they had to be referred by their changeset identifier; either local (number) or global (SHA1 hash). Since Mercurial 1.1, the BookmarksExtension provides a way to identify (and follow) a light branch with a symbolic name, similarly to git. The ''bookmarks'' does not perfectly mimic git branches in the case of two bookmarks pointing to the same head (or two branches referencing the same commit). In git, a commit only updates the working branch while in Mercurial, a changeset updates all the bookmarks pointing to it. (!) BookmarksExtension from Mercurial version 1.2 (to be released) solves this issue and, thus, gets closer in approaching git's lightweight branches. `` /!\ Keep in mind that bookmarks do not propagate over clones, pulls nor pushes because they are not part of the history data nor reflected on the WireProtocol. Related to these branches, git can also handle some special light branches called ''remote branches''. You are not allowed to commit changes directly to a remote branch but to push from another. In Mercurial, once you perform a pull from a different repository, all the newly created heads are yours. Therefore, you can work with them as you like. Finally, Mercurial has another branching functionality called NamedBranches, or also long lived branches. These are part of the history metadata and '''do''' propagate over with the WireProtocol. NamedBranches lie between bookmarks and full repository clones: they are similar to bookmarks in the sense that they are ''lightweight'' and coexist in the same repository, but they are similar to clones in that they can hold multiple heads. There is no git counterpart for them. === Tag model === TODO == Git's staging area == TODO == Command equivalence table == The table presented below is far from being complete due to the large amount of command and switch combinations that git offers. Nevertheless, it tries to cover the most shocking changes when moving from git to Hg: ||<:>'''Git command'''||<:>'''Hg command'''||<:>'''Notes'''|| ||`git pull`||`hg fetch`||Requires the FetchExtension to be enabled.|| ||`git fetch`||`hg pull`||``|| ||`git reset --hard`||`hg revert -a --no-backup`||``|| ||`git revert `''<commit>''||`hg backout `''<cset>''||``|| |
Rey is what folks call him yet he doesn't like whenever folks use his full name. Virgin Islands has always been his house. To fix computers is something he would never give up. Accounting has been his industry for some time. You may constantly discover his website here: http://ankuzic.com/members/zugvirgie/activity/3081/ |
Rey is what folks call him yet he doesn't like whenever folks use his full name. Virgin Islands has always been his house. To fix computers is something he would never give up. Accounting has been his industry for some time. You may constantly discover his website here: http://ankuzic.com/members/zugvirgie/activity/3081/