On Thu, 14 Nov 2013 15:03:29 -0800 (PST)
Vicki Kozel <vickiko...@gmail.com> wrote:

> We've recently switched to Git and Gerrit, and are drafting the best 
> practices workflow for our development team. One thing we want to
> avoid is "merge" commits that have two parents since if these commits
> fail Gerrit's review it is hard to rebase them. 
> I know that "git pull" will do the "fetch" + "merge" that may create
> those two-parent commits. Instead we recommend to do:
> on the feature branch:
> git fetch
> git rebase origin master
> or
> git pull --rebase origin master
> The problem with this last command is that it does not put my local
> commit on top of commits from origin. So if I need to amend my last
> local commit - I can't - since it's not on top of history any longer.
> To amend this commit I have to run rebase --interactive, but we are
> trying to avoid commands that are either complicated or numerous. Is
> there a way to run git pull 
> --rebase in such a way that my latest local commit ends up on the top
> of commit history?

Did you try it?

>From the git-pull manual:

    Rebase the current branch on top of the upstream branch after
  fetching. If there is a remote-tracking branch corresponding to the
  upstream branch and the upstream branch was rebased since last
  fetched, the rebase uses that information to avoid rebasing non-local

The key words are "Rebase the current branch on top of the upstream
branch", which means your call

git pull --rebase origin master

would first fetch master from origin then rewind whatever branch you're
currently have checked out to point to the same commit origin/master
now does and then apply the series of commits defined by
<yourbranch>..origin/master (against the the pre-pull state of
origin/master) to your checked out branch <yourbranch>.  Should that
succeed, you got your local commits exactly "on top" -- that's the
essense of rebasing.

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to