Reset a single file only to a specific commit
Answered
How can I do the equivalent of this
git checkout 25484aadb20bad868ffefef91c4309c310a33e83 -- src/main/java/bg/vivacom/commerce/storefront/controllers/ecare/setting/mycontact/advised/MyContactAdvicedController.java
inside of Intellij for a single file
Please sign in to leave a comment.
1. Right-click on the file in the project view, then "Git -> Show history"
2. In the opened tool window, select the revision you want to revert to, right-click on it, and select "Revert commit"
If an exact file should be reverted, use "Get" action: https://i.imgur.com/kyhBMid.png
Thak you for information about `Get`. I'd like to mention that it is not working for my case, because I need not the file in state it was some commits ago, but just to revert one file in one commit added some days ago. Currently I have done next:
Little bit more details. There is big configuration file. which updated by many devs. At some moment need to undo changes commited some days ago, but save other changes commited during that days. Here needed exactly to revert one commit, because with `checkout` ot JB `Get` I get the file in state it was some days ago without new commits by other devs.
Starostin 450503
You can also you "Revert selected changes" or "Cherry-pick selected changes" (Select a commit, in right panel choose desired file -> Right click on it and choose desired option).
There is the “Get from revision” option that does just what the OP asked for. Click on a commit in the tree graph, then right-click on a file in the commit details panel.
Doesn't work on folders, though. You get the option for a folder, but it only resets files that were edited in that particular commit, so there could be other files that got edited since that won't be reset. `git checkout --no-overlay $ref -- $folder` does that properly.