Sometimes, you have done wrong reorganization commits by command git rebase -i COMMIT_ID
. It can be recovered from wrong actions by using command: git reset HEAD@{NUMBER}
.
Warning1: This can be recovered limited actions done by git
tool.
Figure 1: git reflog show
Using by command: git reflog show
, it will show recent history you do with git commands.
You can find out information from this limited list and choose one item to recover to that one. You need to remember the item with its HEAD@{NUMBER}
and put it to command: git reset HEAD@{NUMBER}
. After finishing git reset command, status of current commit is rollbacked to HEAD@{NUMBER}
you want and you can start to do right something(s) for this repository. If you have done right ones and wish push the right ones to remote repository, it’s good time to do it.
Warning2: If you have done to force pushed wrong commits to remote repository, this situation will become complicated because it affect other members' local repository. It’s hard to rollback, so I recommend you should accept this situation and first fetch/pull down to a branch at current local repository. If there is no conflict happened at local repository, and then you can git push merged results to that branch at remote repository.
Please think twice before typing command: git push -f REMOTE-DESTINATION-REPOSITORY REMOTE-BRANCH-NAME
.