Date: prev next · Thread: first prev next last
2010 Archives by date, by thread · List index


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.


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.