The
git reset --hard
command makes the working tree exactly match HEAD.# removes staged and working tree changes
# of committed files
git reset --hard
If you have tracked files with modifications, you lose these changes with the above command.
|
The reset command does not delete untracked files. If you want to delete them also see Recovering lost commits.
|
27.1. Using git reset to squash commits
git reset, squash commits As a soft reset does not remove your change to your files and index, you can use the
git reset --soft
command to squash several commits into one commit.
As the staging area is not changed with a soft reset, you keep it in the desired state for your new commit. This means that all the file changes from the commits which were reseted are still part of the staging area.
# squashes the last two commits
git reset --soft HEAD~1 && git commit -m "new commit message"
The interactive rebase adds more flexibility to squashing commits and allows to use the existing commit messages.
0 comments:
Post a Comment