[Libreoffice] newish to git: howto recover from bad merge?

Caio Tiago Oliveira caiot1 at gmail.com
Fri Nov 19 18:17:33 PST 2010


Michael Meeks, 19-11-2010 09:23:
>>  Any pointers for the uninitiated would be awesome.
>
> 	It rather depends if you have your own changes, if not you could do git
> reset --hard<previous-version>  to throw away your changes, and then git
> pull; otherwise it is harder.

Thanks to all for the tips.

Here goes mine:
avoid using "git reset --hard" directly when you just want to update, 
branch, etc. Just use git stash.

Git stash is a LIFO, but you can just ignore that for now if you want.

$ git stash
is the same as
$ git stash save

and it will save your local changes (state) to a stash and run "git 
reset --hard". So you can easily run:
$ git stash pop

which will pop the state from the stash and apply to HEAD.

So you can run:
$ git stash
$ git pull  # or rebase, branch...
$ git stash pop
# fix the conflicts, if any
# in this case, git stash drop

if it sounds too hard to fix the conflicts, it will be as smart as it can:
$ git branch fixconflicts

it will apply the state on the top of the commit it was saved from. It 
won't conflict in any way, so you can fix the conflicts on the branch 
and merge later.


Since it's a list, you can stash even if you just want to delete some 
changes. You can consider it as a recycle bin.



More information about the LibreOffice mailing list