How to update particular folder/file from central repository in Git?

喜你入骨 提交于 2019-12-04 22:23:25

问题


Is there a way to update folder or file alone in Git? I had cloned from central repository and wish to update only specific folder/files.


回答1:


you can use git fetch to update the objects in your local clone, and then you can git checkout those particular files.

For example - if your remote is called origin and you only want to update main.c from the master branch you can do this:

git checkout origin/master main.c

This will update the file in your working directory and add it to the index ready to be committed on your local branch.




回答2:


No, you can only fetch/pull commits, which will affect the entire repository.



来源:https://stackoverflow.com/questions/6138817/how-to-update-particular-folder-file-from-central-repository-in-git

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