![]() In that case, just use the reflog approach above to jump back to the reflog entry where you made the commit(s). Since Git actually just makes commits from the index, all you have to do is copy the desired commit into the index. If you did do this while you had other unpushed commits, then you will have lost them. Once you have done these two steps, its safe to git commit the result. Or for the same effect, you could reset -hard to the origin branch: $ git reset -hard origin/my-branch you have no unpushed commits/changes - then you could just delete the local branch with git branch -D and then check it out again: $ git checkout my-branch Git Flow is not a magic word Im after, since we just share the Developer -branch. So I need to roll it back to not break others work as well. And it could take hours, days, weeks before I make the last commit. If the rebase is the only thing you have done on the branch, i.e. If you want to destroy the last commit and throw away any uncommitted changes, use a hard reset. A coworker makes a commit, and merges it in, and his code breaks because mine didnt work. Update: As mentioned in comments and other answers, you can also use ORIG_HEAD as an easier way to find where to reset to: git reset ORIG_HEAD -hard Alternative approach ![]() To find the right place to reset to, you just pick the entry closest to the top that doesn't start with "rebase". ![]() Now you should be back to before the rebase started. $ git reflogĭeafcbf checkout: moving from master to my-branch When you revert to a previous commit, the revert is also a commit. You can use the reflog to find the first action before the rebase started and then reset -hard back to it. There are three possible scenarios, Just go to the previous commit and then come back to latest commit (temporary jump) Go back to previous commit and modify some code there but don’t want to lose the current update history too Go back to previous commit and discard all the new updates after that. You can use GitHub Desktop to revert a specific commit to remove its changes from your branch.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |