LKBEN11583: Remove a local git commit not pushed yet.
Symptom
You need to undo one or two local git commits
Cause
Can happen.
Solution
As long you have not pushed your changes to the remote you can use the following command to go one step back.
First check with "git status". This will show you how far you are ahead.
e.g.
$ git status
On branch main
Your branch is ahead of 'origin/main' by 2 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
To revert one local commit:
$ git reset HEAD~1
You can check with "git status" again. This will show 1 commit ahead.
$ git status
On branch main
Your branch is ahead of 'origin/main' by 1 commit.
(use "git push" to publish your local commits)
Another "git reset HEAD~1" will result in "Your branch is up to date with 'origin/main'.
Have fun.
Disclaimer:
The information provided in this document is intended for your information only. Lubby makes no claims to the validity of this information. Use of this information is at own risk!About the Author
Author:
- Keskon GmbH & Co. KGWim Peeters is electronics engineer with an additional master in IT and over 30 years of experience, including time spent in support, development, consulting, training and database administration. Wim has worked with SQL Server since version 6.5. He has developed in C/C++, Java and C# on Windows and Linux. He writes knowledge base articles to solve IT problems and publishes them on the Lubby Knowledge Platform.
Latest update: 11/07/2022