Quantcast
Channel: How do I delete a commit from a branch? - Stack Overflow
Viewing all articles
Browse latest Browse all 80

Answer by CommaToast for How do I delete a commit from a branch?

$
0
0

Here's another way to do this:

Checkout the branch you want to revert, then reset your local working copy back to the commit that you want to be the latest one on the remote server (everything after it will go bye-bye). To do this, in SourceTree I right-clicked on the and selected "Reset BRANCHNAME to this commit". I think the command line is:

git reset --hard COMMIT_ID

Since you just checked out your branch from remote, you're not going to have any local changes to worry about losing. But this would lose them if you did.

Then navigate to your repository's local directory and run this command:

git -c diff.mnemonicprefix=false -c core.quotepath=false \push -v -f --tags REPOSITORY_NAME BRANCHNAME:BRANCHNAME

This will erase all commits after the current one in your local repository but only for that one branch.


Viewing all articles
Browse latest Browse all 80

Trending Articles