Git: Version 1.6.6

The next major version of Git—1.6.6—should be out any day now.  At which point I will let you guys know.  But I wanted to go ahead and tell you about the changes to take note of.

git-config

In your config files, variables that take paths can begin with ~/ or ~user/ and will be expanded as expected.  Something that caught Chris out today, actually.

git-checkout

If the remote repository has a branch called ‘foo’, and you do not have a local branch called ‘foo’, then the command:

$ git checkout foo

will create and checkout a local version of the remote branch.  It will be the same thing as currently doing:

$ git checkout -t origin/foo.

git-fetch

There are a few new options to this command, but one really important one: --prune.  In Git 1.6.6 you can run:

$ git fetch --prune origin

which does the same thing as:

$ git fetch origin && git remote prune origin

git-merge

Has a new option: --ff-only.  This will make the merge fail if it is not a fast-forward.  Currently you can do this by pushing.  For example, if I wanted to merge ‘foo’ into ‘bar’ but only if it would fast-forward, then I would have to do:

$ git push . foo:bar

But now if I am on the ‘bar’ branch I can do:

$ git merge --ff-only foo

Which semantically makes more sense.  The git-push form makes sense, but it is very idiomatic Git, whereas the new git-merge usage is very readable.

Because git-pull calls git-merge, it also has the –ff-only option.

git-rebase –interactive

Has a new command called ‘reword’.  It does the same thing ‘edit’ does during an interactive rebase, except it only lets you edit the commit message without returning control to the shell.  This is  extremely useful.  Currently if you want to clean up your commit messages you have to:

$ git rebase -i next

Then set all the commits to ‘edit’.  Then on each one:

# Change the message in your editor.
$ git commit --ammend
$ git rebase --continue

Using ‘reword’ instead of ‘edit’ lets you skip the git-commit and git-rebase calls.

git-notes

This is completely new.  It lets you add notes to commits without actually changing the commit.  The notes are separate objects in the Git database which are associated with the commits.  If you are in charge of a repository then you may likely find this useful for keeping notes on various commits in dev branches.

git-push

A lot of people were pissed off with Git 1.6.0 because it broke backwards compatibility with a number of commands, even though the community tried to tell people in advanced.  Git 1.7.0 will be  coming out after 1.6.6, and again there will be compatibility issues.  So this time around the community is really making sure that people know about it, by issuing huge warnings with commands  that are going to change.

This relates to git-push because two uses of the command will not work by default in 1.7.0:

1. Trying to push into the currently checked out branch.

2. Trying to git push $remote :$foo where $foo is the current HEAD in $remote.

Because both of these will be disabled in 1.7.0, you will see loud warnings for them in 1.6.6.  You really should not be doing either of these things anyways.

Related posts:

  1. Undoing Mistakes Easily in Git
  2. Cleaner Git Log With Merges
  3. Working With Git
  4. More Info From Git Branches
  5. Basic Overview of Bare Git Repositories
0 Comment   |   Posted in Version Control,blog by EricR on January 20, 2010