Description
git-backport
fetches a commit from a remote repository and applies it on top of the current branch. Conceptually git-backport
is similar to the following two Git commands:
git fetch <REMOTE-REPO> <HASH>
git cherry-pick FETCH_HEAD
git-backport
will always use the commit message "Backport <HASH>"
for the new commit to make it easier to create a "backport pull request" (for example via git-pr-create).
Usage
git-backport [options] --from <REMOTE-REPO> <HASH>
Examples
git backport --from https://github.com/openjdk/jdk9 8f73a84a15dacfa2cfa6caac3c2a7f1edad0b00f
Configuration
git-backport [options] <HASH>
-u, --username NAME Username on host
--from REPO Repository to backport from
--verbose Turn on verbose output
--debug Turn on debugging output
--version Print the version of this tool
-h, --help Show this help text
Backporting commits in mercurial repositories
Most mercurial repositories have git mirrors, and it's possible to use the commit in the git mirror repository for backporting. There is sadly no direct link between hg commits and their corresponding git commits. So, to find the right commit, you have to search for the commit message (often including a unique bug ID, good for searching) in the git mirror's commit history.
For example, imagine you wanted to backport commit https://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/5da31e88dbf5 "8047720: Xprof hangs on Solaris" in git. Doing the following won't work:
git backport --from https://hg.openjdk.java.net/jdk9 5da31e88dbf5
The git mirror repository is https://github.com/openjdk/jdk9. What is the corresponding git commit's SHA? To find it, you can search for "8047720" in the git mirror, and that helps you find "8f73a84a15dacfa2cfa6caac3c2a7f1edad0b00f". So, to backport that commit, what you actually want to do is:
git backport --from https://github.com/openjdk/jdk9 8f73a84a15dacfa2cfa6caac3c2a7f1edad0b00f
Source
See GitBackport.java.