
We can also checkout old visions of the working tree. Then we can delete the file from the working tree rm no_use_file Checkout old vision We can remove it from the index git reset no_use_file We create a file no_use_file: touch no_use_fileĪnd add it to the index by mistake: git add. If you added a file to the index but don’t want to commit the file you can remove it from the index via git reset file Now we can clean up these file if nothing is wrong git clean -f Remove new added file from index We can find out new added files in working tree: git statusīefore deleting, we can make a dry-run to see what will happen: git clean -n If we create new files in the working tree but we don’t want to keep them, we can discard and clean up these files. We can revert the deletion by checking out the deleted file: git checkout deleted_file Discard newly added files ĭelete a file by mistake: rm deleted_file We can checkout a deleted file again if we haven’t committed the change. Then we can revert the commit ‘not-wanted changes’: git revert 85191fada91f2d2b1fbb997607309dd8050c07e8 Revert file deletion Then find out the commit name by: git log Then we commit these changes: git commit -a -m 'not-wanted changes' We made not-wanted changes: echo "not-wanted change" > working_file The we commit these changes: git commit -a -m 'another stupid changes'Ĭheckout and restore the file with the previous version: git checkout HEAD^ - working_file Revert a commit We made another stupid changes to file working_file: echo "another stupid change" > working_file We can just checkout the old version: git checkout working_file Revert changes to specific file after committing We made some stupid changes to file working_file echo "stupid changes" > working_fileĪnd we haven’t added the changes to the staging index.

We can directly revert the changes to particular file before committing the changes. We can return the entire working tree to the last committed state if we mess up the working tree: $ git reset -hard HEAD Revert changes to particular file before committing

Check out a particular version of a file.Revert changes to specific file after committing.You can access the block list at any time by hitting CMD + / (CTRL + / on Windows) to.
Gitbook editor revert changes full#
The Editor is full of all sorts of content blocks, like this hint: Check me out I’m an editable hint block, and I think I look pretty great. This window right here is where all your page content comes together.

Revert entire working tree before committing.
