[Numpy-discussion] Another merge at github

Pauli Virtanen pav at iki.fi
Mon Oct 18 05:19:10 EDT 2010


Sat, 16 Oct 2010 23:23:46 -0600, Charles R Harris wrote:
[clip]
> And I just managed the same result on a push to maintenance/1.5.x :-/
> But I know how it happened, I cherry picked from master for a backport
> before updating the 1.5.x branch from github. In Retrospect I probably
> should have reset the head, pulled from 1.5.x, and then reapplied the
> backport. 

I think the main problem is in using

	$ git pull

The solution is: 

	DO NOT USE "git pull"

Instead, use "git fetch" and after that either "git merge" or 
"git rebase". Then it is explicit what you are doing, and it is more 
difficult to get wrong.

OTOH,

	$ git pull --ff-only

is "safe" in this sense. So you could in principle drop

#!/bin/bash
CMD="$1"
shift
case "$CMD" in
    pull)
	exec /usr/bin/git pull --ff-only "$@"
	;;
    *)
	exec /usr/bin/git "$CMD" "$@"
	;;
esac

on your $PATH.

> Live and learn.

I do it like this:

1) Work in a separate topic branch.

2) Do not merge from master while working. Rebasing is OK, but often not
   needed.

3) When done,

   a) If it's just a single commit or a bunch of unrelated commits,
      rebase on upstream/master.

      $ git fetch upstream
      $ git branch tmp HEAD          # make a backup in case you mess up
      $ git rebase upstream/master   # do the rebase

      In case of conflicts:

      $ git add numpy/.../somefile   # mark conflict resolved
      $ git rebase --continue

      If you mess up, you can do

      $ git rebase --abort

      and if you notice the mess-up after rebase has completed, you can do

      $ git reset --hard tmp         # set branch to same point as `tmp`

   b) If it's a work consisting of multiple commits that build on each
      other, you can merge.

      $ git fetch upstream
      $ git merge --no-ff upstream/master

4) Then, check what is going to be pushed:

   $ git log --graph somebranch
   $ git log -p somebranch

   Finally, push directly from the branch:

   $ git push upstream somebranch:master




More information about the NumPy-Discussion mailing list