News for hackers. Stuff that matters.
Re:Mercurial over Git by icefox on Friday April 16, 2010 @03:35PM (#1271667)
"Need to make a new branch? Try git branch--er... I mean 4 seemingly random Git commands that don't include the word branch. "

'git branch <branchname> [start-point]' creates a new branch....

Maybe he is referring to the fact that git branch wont change change branches? You have to use git checkout to actually switch branches.

"Not only is documentation for some important features sparse, the documentation that does exist is rarely ever of the best quality."

I am curious what specifically he was referring to. The docs on git-scm are pretty extensive. Between the docs, books, cheatsheets, videos there is a ton out there. Even the man pages include example usage where many man pages for command line tools do not.

Something I can't help but ponder is that in switching to the second system they already had a grasp of some dvc concepts making it easier and if trying git second would have been easier.

Re:Mercurial over Git by stevelosh on Friday April 16, 2010 @05:11PM (#1271950)
The problem is that every git command tries to be extremely flexible. That means the documentation for command X has to cover everything X can do, and when you're just trying to find out how to do action A you have to skim through all the other crap X can do.

For example, 'git help checkout' clocks in at 236 lines. 'git checkout' can change the revision/branch you're at, create a new branch, or revert files without changing HEAD.

The help output for the equivalent Mercurial commands:

* hg help update: 38 lines * hg help revert: 41 lines * hg help branch: 24 lines

If I want to revert a file's contents in a git repo I need to wade through 236 lines to figure out the exact command I need. With Mercurial I need to wade through 41, because I know: "Oh, I'm reverting a file, I need an 'hg revert' command of some kind."

Mercurial commands each do one thing (rarely two, almost never more than that) and do it well. If you want to combine commands, write a script. This makes the documentation concise and easy to read as you're working.

Git commands each try to be flexible enough to do many different things. The price you pay is that any time you need to read through the documentation it's an exercise in trying to search for a word in a man page and hoping everything you need is somewhere nearby.

Re:Mercurial over Git by viraptor on Friday April 16, 2010 @04:14PM (#1271793)
I think he meant `git checkout -b ...` since that's what people want to do most of the time. What's the use case for creating a branch if you're not going to use it straight away? (and no 'branch' in the command really)
Re:Mercurial over Git by hannibalhorn on Friday April 16, 2010 @08:10PM (#1272302)
I always branch before rebasing. Especially when cleaning up history (merging 5-6 "checkpoint" type commits for a big feature into one, etc.) It makes it easy to get back to where you started and you have the original work for reference purposes.
Re:Mercurial over Git by jshen on Friday April 16, 2010 @06:52PM (#1272192)
does he really have a problem remembering 'git checkout -b ...'? Seems like a non issue to me.
Re:Mercurial over Git by viraptor on Saturday April 17, 2010 @12:21PM (#1273247)
It's not an issue, but it can be an annoyance. Put many of them together and you've got a reason why projects like Ubuntu's 100 papercuts exist. If you have to work with something that just isn't quite right even if it works in the end, it can affect your work.
Re:Mercurial over Git by wmcc on Friday April 16, 2010 @04:15PM (#1271800)
I think the author meant these commands as I'm in the same OS class and this script has been circulating around the class:

$ cat git-create-branch #!/bin/sh

if [ $# -ne 1 ]; then echo 1>&2 Usage: $0 branch_name exit 127 fi

branch_name="$1" git push origin origin:refs/heads/${branch_name} git fetch origin git checkout --track -b ${branch_name} origin/${branch_name} git pull

Re:Mercurial over Git by theli0nheart on Friday April 16, 2010 @04:31PM (#1271839)
Wow...just wow. Why would you do this to yourselves?

First of all,

    git push origin origin:refs/heads/${branch_name}
is totally unnecessary when creating a new branch.

I see that there are remote branches you want to track. It's simple, no need for a script. Just make sure you are synced with the current version of the repo you are using (using `git pull`). Then:

    git checkout --track -b bugfix origin/bugfix
Easy as pie. I even have an alias set when I want to do this, so I just call

    git cot bugfix origin/bugfix
To create a new branch locally (that doesn't track a remote), just call

    git checkout -b new-feature
Note: When using `git pull`, `git fetch` doesn't need to be called. Pulling changes will fetch them for you automatically.
Re:Mercurial over Git by davidw on Friday April 16, 2010 @05:01PM (#1271926)
That's not simple. Simple would be doing what everyone wants it to do with one command that's really easy to remember/discover.
Re:Mercurial over Git by pyre on Friday April 16, 2010 @05:15PM (#1271957)
> Simple would be doing what everyone wants it to do with one command

Everyone comes to the plate with different experiences/expectations. You can't hope to satisfy everyone.

Re:Mercurial over Git by jshen on Friday April 16, 2010 @07:01PM (#1272205)
how could it be simpler?
Re:Mercurial over Git by tghw on Friday April 16, 2010 @08:30PM (#1272332)

  hg branch new-feature
If you want it to branch from a different changeset than the one you're on, then:

  hg update deadbeef
  hg branch new-feature
No flags, no orgin/newfeature (what does that even mean?), just the commands describing exactly what you're doing.
Re:Mercurial over Git by jshen on Friday April 16, 2010 @08:44PM (#1272350)
# this creates the branch and switches to it (i.e. does a checkout)

git checkout -b new-feature

The only diff is -b, which is fine to me because it makes it clear that you are doing two things. You don't need the origin/newfeature stuff for the common case. I'm assuming this is what 'hg branch new-feature' is doing. How do you create a branch and not switch to it?

Re:Mercurial over Git by tghw on Friday April 16, 2010 @09:24PM (#1272412)
> How do you create a branch and not switch to it?

  hg branch new-feature
  hg update default
But why would you not want to switch to a branch you just created? Why create the branch if you're not going to work on it?
Re:Mercurial over Git by stevelosh on Saturday April 17, 2010 @10:28AM (#1273067)
Actually that won't create a new branch.

'hg branch foo' just marks the working directory as branch foo. The 'hg update default' would then update back to the default branch and mark the working directory as being on 'default'.

To really just create a new branch you do: 'hg branch foo; hg commit -m "Create a new branch."' Two steps, but like you said, it's probably not something you'd be doing very often anyway.

Re:Mercurial over Git by jshen on Saturday April 17, 2010 @01:11AM (#1272655)
I don't presume to know what is necessary by everyone's situation. If the argument is that mercurial is better because you don't have to use -b, well that's weak sauce.
Re:Mercurial over Git by davidw on Saturday April 17, 2010 @02:39AM (#1272730)
I actually use git, myself, but it's not just the -b; there's all kind of stuff like that in git's "user interface". It gets annoying at times.
Re:Mercurial over Git by davidw on Saturday April 17, 2010 @06:53AM (#1272897)
Also, while it makes it 'a bit annoying' for people like me, I wonder if it will rule git out when it comes to Big Companies and people who are not so computer literate. The last time I looked at the git/windows thing, it was pretty ugly and not nearly as easy to use as turtlesvn.
Re:Mercurial over Git by jshen on Saturday April 17, 2010 @11:19AM (#1273150)
i'm at a big company that everyone has heard of, and we use git.
Re:Mercurial over Git by davidw on Saturday April 17, 2010 @04:38PM (#1273661)
Without more information, I can't really say if you're contradicting me thesis or not. I can easily imagine a small group of git users in any big company, but not so much a larger group that includes a lot of less technical users.
Re:Mercurial over Git by SlyShy on Friday April 16, 2010 @04:45PM (#1271884)
That's a very odd and circuitous way of doing something that is already built-in, I've got to say.