Answers for "erase commit from git repo"

5

git remove commit

# Removes latest commit from the stash, KEEPS changes
git reset --soft HEAD~

# Removes latest commit from the stash, DELETES changes
git reset --hard HEAD~
Posted by: Guest on November-27-2020
1

erase commit from git repo

git reset <reference_to_commit>  #default flag --mixed
#Commits are reference with the HEAD~ not SHA.
#HEAD~1 is the 2nd commit, HEAD~2 is the 3rd commit, HEAD~3 is 4th commit....
#NB: Be aware of the active branch.

git reset --mixed HEAD~<reference_no.>  #Moves HEAD to the referenced commit, 
# and moves commits before it to the working directory.

git reset --soft HEAD~<reference_no.>    # Moves HEAD to the referenced commit, 
# and moves commit before it to the staging index.

git reset --hard HEAD~<reference_no.> #Moves HEAD to the referenced commit, 
# and moves commits before it to the trash and erased from tree.

#NB: All commits that are reset are kept in the trash for 30days.
Posted by: Guest on September-09-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language