Remove commit from main branch in Git

I forgot to make a branch before making some code updates, and now I need to go back to the original commit and delete all commits after the original. The work was saved somewhere, so I do not risk losing it.

I used "git reset --hard {SHA}" to reset back to where I needed it, but now I have all the commits that were executed after the initial commit, waiting to return and synchronize with my main copy.

I want to delete all commits from 6/10/2015 to 7/2/2015, since they are no longer needed. Does anyone know how to do this?

enter image description here

+4
source share
2 answers

Removing deleted commands from any branch [Master is a branch]

- , - , , .

, - 1

- 3

  • reset reset HEAD , : git reset --hard {SHA}

    • {SHA} -
  • ( , )

  • reset , HEAD - git reset --hard {SHA}

    • , you reset to, -
  • , : git push -f

+9

, git push -f, .

( , , ), reset , (git reset --hard origin/master, master). git revert, , .

+3
source

All Articles