简体   繁体   English

git:只提取某些文件

[英]git: Pulling only certain files

I'm using the TortoiseGit client on Win XP. 我在Win XP上使用TortoiseGit客户端。 In a particular folder, I have 3 modified files, whose modifications I wish to trash. 在一个特定的文件夹中,我有3个修改过的文件,我希望删除它们的修改。 In other words, I want to check out the latest versions of these three files from the remote repository. 换句话说,我想从远程存储库中查看这三个文件的最新版本。 Note that there is another modified file in the same directory that I wish to leave as is. 请注意,在我希望保留的同一目录中有另一个已修改的文件。 How do I get the latest version of only these 3 files? 如何获取这3个文件的最新版本?

Thanks - Dave 谢谢 - 戴夫

A checkout with pathnames does not affect HEAD : 带路径名的结帐不会影响HEAD

git checkout origin/master -- file1 path/file2 path/file3

Assuming default upstream remote/branch names (eg after a git clone) 假设默认上游远程/分支名称(例如在git clone之后)

Note that the three named files will be overwritten without warning . 请注意,三个命名文件将被覆盖而不会发出警告 Any uncommitted local changes to these named files will be lost. 这些命名文件的任何未提交的本地更改都将丢失。

From the project root invoke the context-menu (Click right-mouse-button assuming you are right-handed ;-). 从项目根目录调用上下文菜单(单击鼠标右键,假设你是右撇子;-)。

Select TortoiseGit > Revert... 选择TortoiseGit > Revert...

The Revert dialog will show all files you in your repository that you have modified. “还原”对话框将显示您已修改的存储库中的所有文件。 You can choose the ones you wish to revert by selecting the check box and then pressing OK. 您可以通过选中复选框然后按确定来选择要还原的那些。

This brings the selected files back to their original state. 这会将所选文件恢复为原始状态。

You can then get the latest versions of these files from the shared repository using the Pull... operation from the TortoiseGit context menu (Of course you might wish to commit/stash other changes you have locally). 然后,您可以使用TortoiseGit上下文菜单中的Pull ...操作从共享存储库中获取这些文件的最新版本(当然,您可能希望提交/存储您在本地进行的其他更改)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM