Pulling just one directory out of a git repo

后端 未结 1 859
故里飘歌
故里飘歌 2020-12-08 23:09

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

1条回答
  •  情歌与酒
    2020-12-08 23:53

    git pull fetches and merges the remote branch.

    .gitignore works only locally, and will hide matching entries from showing up on git status and being added to the index with git add. It's not what you want.

    What you want to do, is fetch the remote branch, and from that, extract the dir/file you need.

    $ git fetch  
    $ git checkout / -- relative/path/to/file/or/dir
    

    the file/dir should now be in your branch and added to the index.

    0 讨论(0)
提交回复
热议问题