how to remove the last commit from remote git repo? It was not added from its local repo. It was added from different local repo by accident. I tried all recommendations and non eworked
Asked
Active
Viewed 507 times
1
-
Does this answer your question? [Remove last commit from remote git repository](https://stackoverflow.com/questions/8225125/remove-last-commit-from-remote-git-repository) – GoodDeeds Jan 30 '20 at 20:23
1 Answers
1
this may help (from GitHub)
Removing the last commit
To remove the last commit from git, you can simply run
git reset --hard HEAD^
If you are removing multiple commits from the top, you can run
git reset --hard HEAD~2
to remove the last two commits. You can increase the number to remove even more commits.
If you want to "uncommit" the commits, but keep the changes around for reworking, remove the
"--hard": git reset HEAD^
which will evict the commits from the branch and from the index, but leave the working tree around.
If you want to save the commits on a new branch name, then run
git branch newbranchname
before doing the git reset.

eliftozoglu
- 21
- 1