开发者

Restoring a specific file from a commit

开发者 https://www.devze.com 2023-02-27 20:48 出处:网络
I\'m using Git with GitGUI. I did a commit to several files (and have since committed again) and now I see a test is not working. I checked out some commits and found the culprit. I now want to resto

I'm using Git with GitGUI.

I did a commit to several files (and have since committed again) and now I see a test is not working. I checked out some commits and found the culprit. I now want to restore the changes made to a specific file, back to a certain commit. How can I do that?

A preferred solution will also keep the latest commits in the tree (so I can re-implement them 开发者_Go百科well this time).


You can pass a revision and filename to git checkout to check out a particular version of that file:

git checkout abc123 -- filename

Now your working copy will have the version of filename from commit abc123, and you can commit that in order to restore back to that version of that file.

0

精彩评论

暂无评论...
验证码 换一张
取 消