[Plone-conference] A tip about working with git at sprints

Andreas Zeidler andi at pyfidelity.com
Sun Oct 14 08:50:57 UTC 2012


On 14 Oct 2012, at 01:40, Maurits van Rees <m.van.rees at zestsoftware.nl> wrote:
> Op 14-10-12 01:29, David Glick schreef:
>> Instead of doing "git pull," you can do "git pull --rebase". This will make git redo your commit(s) after the one(s) that happened on github, so that no additional merge commit is necessary unless something conflicts.
> 
> Ah, I have not used that one yet.  Should work nicely, thanks.  I usually do interactive rebases.
> 
> In case you have already done a normal git pull and you have ended up in the situation David mentions, you can also do `git rebase -i HEAD^^` to interactively rebase the last two commits (or more, if you add more carets).

you don't even have to remember this — a simple `git rebase` (without any further arguments) will rebase your changes neatly, even after having "pulled" already.  git's bash completion and prompt (https://gist.github.com/1234986) are your friends here:  if your prompt suddenly shows "(master u+1-2) $" you just `git rebase`.

> If you have not done this before, you may want to first make a quick copy or tarball of your clone, just to be safe.

i've more or less stopped making any backups wrt git.  it's pretty defensive, i.e. the chances it leaves you in a state you can't recover from are very slim.  ymmv, of course.  in any case, there's also `git reflog`, which you can think of as your "undo" feature: doing a `git reset …` to any of the SHAs listed there will take you back, even across switching branches, pulls, merges, whatever…

cheers,


andi

-- 
pyfidelity.com



More information about the Plone-conference mailing list