Navigation Menu

Skip to content

I accidentally force pushed to my repo #23242

Answered by lee-dohm
Ben3eeE asked this question in New to GitHub
Discussion options

You must be logged in to vote

If I’m understanding correctly, you’re talking about a scenario like the following:

  1. You have a repo named ben3eee/some-repo
  2. You create a few commits on branch some-branch
  3. You push some-branch to ben3eee/some-repo on GitHub using git push
  4. You squash the commits into one using git rebase -i
  5. You  force push some-branch to ben3eee/some-repo on GitHub using git push -f
  6. You now want to restore some-branch to the way it was before step #4

The great thing about Git though is that it does it’s very best to never lose data, so the version of the repository before step #4 is still available as long as too much time hasn’t passed. The exact definition of “too much time” is kind of fuzzy and depend…

Replies: 7 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants