BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

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

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

This item in japanese

Bookmarks

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
Style

BT