Git: pulling only specific files

I am using the TortoiseGit client in Win XP. In a specific folder, I have 3 modified files whose changes I want to delete. In other words, I want to check the latest versions of these three files from a remote repository. Note that there is another modified file in the same directory that I want to leave as is. How to get the latest version of only these 3 files?

Thanks - Dave

+6
source share
2 answers

Checking with path names does not affect HEAD:

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

Assuming default remote / branch names by default (e.g. after git clone)

Note that the three named files will be overwritten without warning. Any uncommitted local changes to these named files will be lost.

+8
source

From the project root, call the context menu (right-click, assuming you're right ;-).

Choose TortoiseGit > Revert...

The Check In dialog box displays all the files that you changed in your repository. You can select the ones you want to return by checking the box and then clicking OK.

This returns the selected files to their original state.

Then you can get the latest versions of these files from the shared repository using the Pull ... operation from the TortoiseGit context menu (of course, you might want to commit other changes that you have locally).

+2
source

Source: https://habr.com/ru/post/900783/


All Articles