I have a git repo that I want to do a pull from. I do a normal git pull with no problems. The issue is that I want just one certain directory out of the repo. My thinking was that I could use a .gitignore file with a rule like this:
#Ignore all files
/
#Except the one I want
!/temp
The problem is this doesn’t work. Is that the right way to do it or is there a better way?
git pullfetches and merges the remote branch..gitignoreworks only locally, and will hide matching entries from showing up ongit statusand being added to the index withgit add. It’s not what you want.What you want to do, is
fetchthe remote branch, and from that, extract the dir/file you need.the file/dir should now be in your branch and added to the index.