![]() ![]() In that case, just use the reflog approach above to jump back to the reflog entry where you made the commit(s). Learn about both, and how to implement them correctly. If you did do this while you had other unpushed commits, then you will have lost them. Admins have two options to roll back to a previous Git commit: the git reset or git revert command. Since Git actually just makes commits from the index, all you have to do is copy the desired commit into the index. ![]() Or for the same effect, you could reset -hard to the origin branch: $ git reset -hard origin/my-branch Once you have done these two steps, its safe to git commit the result. 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 If the rebase is the only thing you have done on the branch, i.e. 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 GitHub) There, any changes diverging from your current. The second command will force-push to the default remote (i.e. and reset your local repository to the state of the current HEAD - 5 commits. To find the right place to reset to, you just pick the entry closest to the top that doesn't start with "rebase". The first command will wipe any uncommitted changes in your current working copy. Now you should be back to before the rebase started. $ git reflogĭeafcbf checkout: moving from master to my-branch Learn more about Git generally in our guide Git vs SVN: Pros and Cons of Each Version Control System. It covers methods using both the revert and reset commands, and explains the differences. You can use the reflog to find the first action before the rebase started and then reset -hard back to it. Git has the ability to revert the last commit, and this tutorial shows you exactly how. I can revert and reset old commits, but theres no option in the history view or the commit details view to just check out an old version I have to do this. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |