- Unstage all files you might have staged with git add:
git reset
- Revert all local uncommitted changes (should be executed in repository root):
git checkout .
- Revert all uncommitted changes
git reset --hard HEAD
- Remove all local un tracked files, so only git tracked files remain
git clean -fdx
- Undo a commit and redo
$ git commit -m "Something terribly misguided"
$ git reset HEAD~
This leaves your working tree (the state of your files on disk) unchanged but undoes the commit and leaves the changes you committed unstaged (so they’ll appear as “Changes not staged for commit” in git status and you’ll need to add them again before committing). If you only want to add more changes to the previous commit, or change the commit message, you could use git reset –soft HEAD~ instead, which is like git reset HEAD~ but leaves your existing changes staged.\
git reset --soft HEAD^
# use –soft if you want to keep your changes
git reset --hard HEAD^
# use –hard if you don’t care about keeping the changes you madegit revert commit-id
To get the commit ID, just use git log. This will revert the given commit
- Hard delete unpublished commits
This will destroy any local modifications.
git reset --hard 0d1d7fc32
Alternatively, if there’s work to keep:
git stash
git reset --hard 0d1d7fc32
git stash pop
This saves the modifications, then reapplies that patch after resetting.
Sharing is Caring !
Subscribe
0 Comments
Most Voted