You may have to retrace your steps, want to cancel the changes to our project.
According to the stage of development, there are several ways to undo your changes using git.
First of all it is good to understand to what state we are at the present moment:
- Unstaged: we changed locally, but we have not yet added the changes using git add
- Staged: added to the repository using git add
- Committed: the file has been committed to the local repository using git commit
Git remove unstaged / untracked changes
Changes or additions have not yet been added to the staged tree.
You can proceed with:
Remove all local changes, saving them for possible use later (put the changes aside):
Remove local changes, saving them in a file:
Git remove staged changes
You can remove all your changes from the current commit, but keep them in your project:
Or you can undo the changes to a single file
Undo the changes, but save them for later
Remove all the changes forever (as in unstaged changes):
Git remove committed changes
Until you push your changes, you have control over what you did without public shame.
Undo changes in a particular commit:
Undo changes in to a file in a commit, keeping them in staged state:
Undo changes in a file in a commit, keeping them in an unstaged state: