Can I pull only certain files from another git repository?

岁酱吖の 提交于 2019-12-01 23:09:25

You can get files from the remote repository using git archive. You could then add and commit the files to your repository. This approach will not preserve history from his branch. See git archive docs for details.

If you want to try to preserve parts of that experimental branch, you could git fetch his repository, and then git rebase his experimental branch onto your repository, editing or skipping commits with conflicts as appropriate. Once you have a cleaned up branch in your repository, you can merge that in. See git rebase docs

You'll have to copy the file directly. Git deals with whole repositories, not single files within them.

I suppose you could set Repository 2 up as a remote repository, fetch (not pull) its branches, then use git checkout to grab a file out of that branch, but that solution could be messy.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!