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.
$ 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
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.Everyone comes to the plate with different experiences/expectations. You can't hope to satisfy everyone.
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.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?
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?'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.
'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.