开发者

How to pull a specific file with GIT? [duplicate]

This question already has answers here: Undo working copy modifications of one file in Git? (15 answers) Closed 9 years ago.

Say you just want to get rid of the changes you've made to one file, and get back to whatever is in the repository. I used to do this in svn:

rm a-file.txt
svn update a-file.txt

What is the equivalent in Git? I know how to fetch/pull evrything fr开发者_StackOverflowom the repository, but how about one single file?


To undo your (uncommitted) changes:

git checkout a-file.txt

If you have committed changes and want to undo them back to a certain previous commit:

git checkout [some-older-commit-ref] a-file.txt

Btw, with Subversion you should have done:

svn revert a-file.txt
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜