Is there anyway I can get rid of this commits and let the last one stay there?
Asked
Active
Viewed 105 times
-2
-
1What are you trying to achieve? One point of version control is to allow you to go back if e.g. you realise you've made a mistake. – jonrsharpe Dec 27 '20 at 19:18
-
Does this answer your question? [Squash my last X commits together using Git](https://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git) – flaxel Dec 27 '20 at 19:24
1 Answers
0
On your master
branch you could do:
git reset --hard \<commit-hash>
git push -f origin master
commit-hash
would be the last commit in your case.
CAUTION: If your remote repo master
is used by multiple people and frequently has changes Pushed to it, you should first consult with your teamates before doing a reset
.
Also if you cannot do the above, you can look at Undo published commits with new commits

flaxel
- 4,173
- 4
- 17
- 30

Dev-vruper
- 421
- 3
- 12
-
**WARNING**: This destroys all commits after the specified one. If you instead want to collapse them into a single commit, consult https://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git – HolyBlackCat Dec 27 '20 at 20:50