Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

- detached HEAD: "git checkout existing_branch" or "git checkout -b new_branch"

- you don't where somewhere and you moved and you can't go back: "git reflog"

- local repo and remote with a different history (e.g: you rebased on a published branch): the whole team to sync with remote except you, then hold. Export your remaining changes as a patch. Reclone. Apply patch.

- remote has a different history than the rest of the team (e.g: you forced push a different history): Delete remote, recreate, repush from one of the team mate, then apply previous solution.

- your messed up your merge and wish to never have done that: "git reset --merge"

- the last commit is not published and you messed it up: "git commit --amend"

- the last commit is published and you messed it up: "git revert HEAD"

But rather than solve problems, better not get them in the first place. Always "git status" before anything, always get a clean working copy before checkout/pull, create a fat gitignore, etc.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: