BT

Git 2.9 Adds New Features to Merge, Rebase, Commit, and More

| by Sergio De Simone Follow 21 Followers on Jun 17, 2016. Estimated reading time: 2 minutes |

Git 2.9 has been just announced. It will bring new features to the merge, rebase, and commit workflows, among many other improvements and bug fixes.

Git merge and pull commands will not allow two branches with unrelated histories to merge unless the --allow-unrelated-histories option is specified. Two branches have unrelated histories when their root commits are not the same, for example, when two branches are used for completely different purposes such as code and documentation. In such cases, it is desirable that git does not silently merge unrelated histories, since this could have unintended consequences. For the “rare” cases where merging unrelated histories is necessary, the above mentioned --allow-unrelated-histories option can be used to force this behaviour.

The rebase command now supports the use of the -x option in non-interactive mode. The -x (--exec) option is used to run a given command at each rebase step. For example, this can be used to run unit tests and thus check that each rebased commit will not break anything. Previously, this could only be done when also passing the -i option. A bug has also been fixed when using git rebase -m to rebase a branch starting from the root, when the rebase failed because it assumed a parent commit exists.

The commit command supports a new commit.verbose configuration option to specify whether it should be verbose by default. Setting this option is the same as giving each time the --verbose option on the command line, which will display an inline diff of the changes. Additionally, git commit --dry-run will now provide the correct outcome in one case when it used to say that committing was not possible, while git commit would have allowed to commit. Finally, a bug has been fixed that made git commit misbehave when an empty message was passed with the -m option.

A new --allow-submodules option to the git clone command makes it possible to clone a repo and then recursively clone all of its submodules without pulling their whole histories, thus making the cloning faster and more efficient.

Git 2.6 also improves convenience by using hooks, which allow to tap into git tasks such as commit, merge, rebase, push, etc. by defining scripts that can be run before or after those tasks. Indeed, a new core.hooksPath configuration option allows specifying which directory hosts your hooks:

git config core.hooksPath /etc/git/hooks

Previously, git looked for hooks in the .git/hooks directory.

Other improvements in Git 2.9 are better detection of file renames, better handling of tabs in git log, and a more informative git describe --contains algorithm. However, the list of improvements and bug fixes provided by Git 2.9 is still long. You can find more details in the release notes.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Git 2.6 ?Git 2.9? by xia xue

Git 2.6 also improves convenience by using hooks, which allow to tap into git tasks such as commit, merge, rebase, push, etc.

Git 2.9??

Possibly a typo mistake. by Miguel Gouveia

In the 6th paragraph I think there is a typo. Is is written "Git 2.6 also improves ..." when it should be "Git 2.9 also improves ...".

As xia xue already mention in the previous post.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

2 Discuss
BT