简体   繁体   中英

git: Pulling only certain files

I'm using the TortoiseGit client on Win XP. In a particular folder, I have 3 modified files, whose modifications I wish to trash. 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?

Thanks - Dave

A checkout with pathnames does not affect HEAD :

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

Assuming default upstream remote/branch names (eg after a 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...

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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