Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Undo git push to branch master

Tags:

git

I did a mistake, I work on branch develop, but I did a git push to branch master. How can I undo that? Thanks!

git push origin c45f349cedfc1df51300a8ebb964088c305f2567:master
WARNING

Any access or any attempt to access this machine without permission is forbidden
and could be subject to criminal and civil penalties.

To protect this system from unauthorised use, viruses and to ensure that the
system is functioning properly, security systems have been installed.

Any unauthorised attempt to stop or bypass one of these security tools is
forbidden.

ATTENTION

Tout acces ou tentative d'acces non autorisee sur ce systeme est interdit
et sujet a des poursuites penales ou civiles.

Pour proteger ce systeme des acces frauduleux et des virus, et pour assurer son
bon fonctionnement, des systemes de securites ont ete installes.

Toute tentative non autorisee pour arreter ou contourner l'un de ces
dispositifs est interdite.
Counting objects: 10, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (10/10), 1.78 KiB | 0 bytes/s, done.
Total 10 (delta 7), reused 0 (delta 0)
To [email protected]:optiq/message-bus.git
   0ca786a..c45f349  c45f349cedfc1df51300a8ebb964088c305f2567 -> master
like image 724
yue Avatar asked Apr 21 '26 22:04

yue


1 Answers

  1. checkout to master

git checkout master

  1. View master last commit

git log --oneline

  1. reset to last commit

git reset --hard lastcommit

  1. force push origin master

git push -f origin master:master

like image 176
maquannene Avatar answered Apr 25 '26 16:04

maquannene



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!