Is there a way to rebase a single commit from a branch onto another branch?
I have this branch structure:
-- -- -- -- -- (Master)
\\
@Charles response is correct. Anyway I ended up using this so many times, most of all to rebase specific config on a project
* a8f9182 (HEAD -> production) production configuration | * daa18b7 (pre) preproduction configuration |/ | * d365f5f (local) local configuration |/ * 27d2835 (dev) amazing new feature that will save the world * | 56d2467 (master) boring state of the art for project |/
that I create a new command for it:
$ cat ~/bin/git-rebaseshot
COMMIT=$1
DEST=${2:-HEAD}
git rebase ${COMMIT}^ ${COMMIT} --onto $DEST
normally you want to autocomplete branch names for that command, so add it sourcing this function (adding to .bashrc or .profile):
_git_rebaseshot ()
{
__gitcomp_nl "$(__git_refs)"
}
git autocomplete will search for it
you can use this command like this:
# rebase config on prepro on actual HEAD
$ git rebaseshot prepro
# rebase config on local onto dev
$ git rebaseshot local dev
# rebase production config on master
$ git rebaseshot pro master
When you divide features correctly, possibities are endless.
* a8f9182 (HEAD -> postgres) BBDD config * a8f9182 (local) local config * a8f9182 (debug) log level config * a8f9182 (dev) new feature |
I guess this is what quilt people like to do.
this command will work anyway with whatever sha/ref you provide:
$ git rebaseshot master
$ git rebaseshot master