I want revert a directory in git - reverting all files inside, as well as removing any files added since that commit. Doing a checkout only seems to satisfy my first requirement, but doesn't delete any files.
Right click on the commit you want to return to and select "Reset master branch to here". Then choose hard from the next menu.
How would I revert just the current directory in Git? Use git checkout instead of reset. git checkout <branchname>~1 -- path/to/directory/you/want/updated should do the trick.
Undoing a commit If you have modified, added and committed changes to a file, and want to undo those changes, then you can again use git reset HEAD~ to undo your commit.
I figured out the simplest solution.
git rm /path/to/dir git checkout <rev> /path/to/dir git commit -m "reverting directory"
Then delete any untracked files.
git rm
Remove files from the working tree and from the index https://git-scm.com/docs/git-rm
git checkout
Updates files in the working tree to match the version in the index or the specified tree. https://www.git-scm.com/docs/git-checkout
git commit
Record changes to the repository https://www.git-scm.com/docs/git-commit
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With