0

I am the maintainer for a project in Git. Sometimes new contributors send patches which are based on an older commit because they forgot to pull the latest changes and rebase to Git master before submitting. I can do this for them, but it takes many steps. How can I do this in one step?

How I do it in multiple steps:

git checkout -b feat/some-patch <commit id of commit he based his patch on>
git pull <his patch> # applies via fast-forward
git rebase master # do what he should have done
git checkout master
git merge feat/some-patch # applies via fast forward

This works, and I avoid merge commits. I wish there was a one liner to do so. I looked at git pull --rebase, but it doesn't do what I expected.

Nathan Tuggy
  • 2,237
  • 27
  • 30
  • 38
James
  • 23
  • 3
  • `git cherry-pick`? http://git-scm.com/docs/git-cherry-pick – Kedar Mar 13 '15 at 04:45
  • Ah, I didn't realize I could use that here. Thanks... After googling a bit, the fastest way I found was: ```git fetch && git cherry-pick FETCH_HEAD``` -- is there a one line version? – James Mar 13 '15 at 07:44
  • See this answer for a possible one-liner http://stackoverflow.com/a/14872590/1268926 – Kedar Mar 13 '15 at 09:13
  • Doesn't look to be exactly what I want, but I think I can write an alias to do what I want... Back later with this :) – James Mar 14 '15 at 08:43
  • I've now figured out a one liner by building a strange git alias... Full code and example here: https://ttboj.wordpress.com/2015/03/16/fancy-git-aliases-and-git-cherryfetch/ – James Mar 16 '15 at 10:23

0 Answers0