Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Delete commits from repository.
# First, check out the commit you wish to go back to (get sha-1 from git log)
git reset --hard 9d3c3a0caa7f7b35ef15adb96fc80fcbb59ac72a
# Then do a forced update.
git push origin +9d3c3a0caa7f7b35ef15adb96fc80fcbb59ac72a^:develop
# Push specific commit
git push origin 9d3c3a0caa7f7b35ef15adb96fc80fcbb59ac72a:develop -f
@icangku
Copy link

icangku commented Jul 26, 2020

@mfi2007 :develop is your branch name

@MamathaKavety29
Copy link

MamathaKavety29 commented Aug 12, 2020

helpful

@Yash-Singh1
Copy link

Yash-Singh1 commented Aug 22, 2020

Thanks 💯

It was helpful

@gmeligio
Copy link

gmeligio commented Aug 26, 2020

Thank you. It saved my pull request.

@ankithans
Copy link

ankithans commented Sep 7, 2020

Thanks a lot for this 🥺

@akhileshgotmare
Copy link

akhileshgotmare commented Sep 17, 2020

Thanks, this is super helpful!

@qlow
Copy link

qlow commented Oct 4, 2020

this saved my ass

@arshbeerSingh
Copy link

arshbeerSingh commented Oct 5, 2020

Super helpful for beginners. Thanks

@tesmojones
Copy link

tesmojones commented Dec 3, 2020

super thank you

@sarahg177
Copy link

sarahg177 commented Dec 4, 2020

When I do the force update an error

ssh: Could not resolve hostname +771a004fba7e893ad31308619231041a4559ebc1^: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
iMac:adeptcare_personnel SarahBaker$ git push origin +771a004fba7e893ad31308619231041a4559ebc1^:develop
error: The destination you provided is not a full refname (i.e.,
starting with "refs/"). We tried to guess what you meant by:

  • Looking for a ref that matches 'develop' on the remote side.
  • Checking if the being pushed ('771a004fba7e893ad31308619231041a4559ebc1^')
    is a ref in "refs/{heads,tags}/". If so we add a corresponding
    refs/{heads,tags}/ prefix on the remote side.

Neither worked, so we gave up. You must fully qualify the ref.
hint: The part of the refspec is a commit object.
hint: Did you mean to create a new branch by pushing to
hint: '771a004fba7e893ad31308619231041a4559ebc1^:refs/heads/develop'?
error: failed to push some refs to 'https://github.com/sarahg177/adept.git'

Why?

@c-faught
Copy link

c-faught commented Dec 12, 2020

Incredible!

@cacrespo
Copy link

cacrespo commented Dec 12, 2020

Genius! 👍

@Jose-cd
Copy link

Jose-cd commented Dec 31, 2020

When I do the force update an error

ssh: Could not resolve hostname +771a004fba7e893ad31308619231041a4559ebc1^: nodename nor servname provided, or not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
iMac:adeptcare_personnel SarahBaker$ git push origin +771a004fba7e893ad31308619231041a4559ebc1^:develop
error: The destination you provided is not a full refname (i.e.,
starting with "refs/"). We tried to guess what you meant by:

  • Looking for a ref that matches 'develop' on the remote side.
  • Checking if the being pushed ('771a004fba7e893ad31308619231041a4559ebc1^')
    is a ref in "refs/{heads,tags}/". If so we add a corresponding
    refs/{heads,tags}/ prefix on the remote side.

Neither worked, so we gave up. You must fully qualify the ref.
hint: The part of the refspec is a commit object.
hint: Did you mean to create a new branch by pushing to
hint: '771a004fba7e893ad31308619231041a4559ebc1^:refs/heads/develop'?
error: failed to push some refs to 'https://github.com/sarahg177/adept.git'

Why?

:develop is your branch name

@ksonawat007
Copy link

ksonawat007 commented Feb 25, 2021

Thanks a lot!!

@talha-ah
Copy link

talha-ah commented Apr 16, 2021

Thanks <3

@dogukaneren
Copy link

dogukaneren commented Jun 13, 2021

Thank you very much <3

@rokyhu
Copy link

rokyhu commented Jun 14, 2021

🤟

@bobbi-henderson
Copy link

bobbi-henderson commented Jul 9, 2021

oh my gosh, thank you so much!

@Ngomana
Copy link

Ngomana commented Aug 27, 2021

💯💯💯💯

@Palak-Srivastava
Copy link

Palak-Srivastava commented Oct 13, 2021

How do I delete commit directly on web interface?

@tsarbuig
Copy link

tsarbuig commented Jan 1, 2022

amazing, thanks bro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment