简体   繁体   中英

How to undo git add, commit and push so that I can see my changes in my vscode once again?

I find it pretty helpful to see the files and precisely which files have been changed in vscode (the green for additions and the red for deletions). Now that I have used git add , commit and push , those are gone. Can I undo those commands so that I can get my helpful colors in vscode again?

After add and commit, you have no modified files (in comparison to HEAD). After push, you have no outstanding commits (in comparison to the remote). Therefore you are at a completely neutral state and there is nothing to mark. That's why the marks are gone.

If you merely want to know what you changed in your most recent commit, you can diff against the previous commit. But that does not cause the markings to reappear in the GUI.

However, here's a trick I like to use in this situation. Make a new branch, switch to it, and reset it (mixed or soft) to the previous commit. Presto, there's your "undo". All your changes are illuminated in the interface again.

You can even continue working from this state: Make new changes, commit, and cherry pick that onto the real branch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM