Skip to content

Instantly share code, notes, and snippets.

@dsci
Created November 8, 2011 12:52
Show Gist options
  • Select an option

  • Save dsci/1347672 to your computer and use it in GitHub Desktop.

Select an option

Save dsci/1347672 to your computer and use it in GitHub Desktop.
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
@clnsdzy

clnsdzy commented Jan 21, 2020

Copy link
Copy Markdown

Does that mean I'll have to clone the repo first?

@kajc10

kajc10 commented Mar 30, 2020

Copy link
Copy Markdown

Thank you!!

@Ritik8755

Copy link
Copy Markdown

thank you sir

@sAVItar02

Copy link
Copy Markdown

Thanks a lot, this saved me from doing a lot of work again

@sam-malanchuk

Copy link
Copy Markdown

Thanks for the help!

@diadras

diadras commented Jun 26, 2020

Copy link
Copy Markdown

LITERALLY just saved my butt again. I commented in 2019 saying thanks knowing I would need this sometime in the future. Today I needed this again and digged through my email for a link to this post and found it. Thanks again!!

@ahampriyanshu

Copy link
Copy Markdown

Thank a lot !

@midastown

Copy link
Copy Markdown

Works like a charm~~

@mfi2007

mfi2007 commented Jul 14, 2020

Copy link
Copy Markdown

Can anyone explain the process step by step for beginners? (a video tutorial would be better)

@icangku

icangku commented Jul 26, 2020

Copy link
Copy Markdown

@mfi2007 :develop is your branch name

@MamathaKavety29

Copy link
Copy Markdown

helpful

@Yash-Singh1

Copy link
Copy Markdown

Thanks 💯

It was helpful

@gmeligio

Copy link
Copy Markdown

Thank you. It saved my pull request.

@ankithans

Copy link
Copy Markdown

Thanks a lot for this 🥺

@akhileshgotmare

Copy link
Copy Markdown

Thanks, this is super helpful!

@janrabek

janrabek commented Oct 4, 2020

Copy link
Copy Markdown

this saved my ass

@arshbeerSingh

Copy link
Copy Markdown

Super helpful for beginners. Thanks

@tesmojones

Copy link
Copy Markdown

super thank you

@sarahg177

Copy link
Copy Markdown

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
Copy Markdown

Incredible!

@cacrespo

Copy link
Copy Markdown

Genius! 👍

@Jose-cd

Jose-cd commented Dec 31, 2020

Copy link
Copy Markdown

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

@khushalsonawat

Copy link
Copy Markdown

Thanks a lot!!☺☺

@talha-ah

Copy link
Copy Markdown

Thanks <3

@dogukaneren

Copy link
Copy Markdown

Thank you very much <3

@rokyhu

rokyhu commented Jun 14, 2021

Copy link
Copy Markdown

🤟

@bobbi-henderson

Copy link
Copy Markdown

oh my gosh, thank you so much!

@Ngomana

Ngomana commented Aug 27, 2021

Copy link
Copy Markdown

💯💯💯💯

@Palak-Srivastava

Copy link
Copy Markdown

How do I delete commit directly on web interface?

@tsarbuig

tsarbuig commented Jan 1, 2022

Copy link
Copy Markdown

amazing, thanks bro

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