简体   繁体   English

如何从 Git 的中央存储库更新特定文件夹/文件?

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

Is there a way to update folder or file alone in Git?有没有办法单独更新 Git 中的文件夹或文件? I had cloned from central repository and wish to update only specific folder/files.我从中央存储库克隆并希望只更新特定的文件夹/文件。

you can use git fetch to update the objects in your local clone, and then you can git checkout those particular files.您可以使用git fetch更新本地克隆中的对象,然后您可以git checkout这些特定文件。

For example - if your remote is called origin and you only want to update main.c from the master branch you can do this:例如 - 如果您的遥控器被称为 origin 并且您只想从 master 分支更新main.c您可以这样做:

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.这将更新您工作目录中的文件并将其添加到准备提交到本地分支的索引中。

No, you can only fetch/pull commits, which will affect the entire repository.不,您只能获取/拉取提交,这将影响整个存储库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从中央远程存储库进行git提取? - How to git fetch from a central remote repository? 从 git 中提取特定文件或特定文件夹 - Pull a particular file or a particular folder from git 如何重命名GIT中央存储库 - How to rename GIT central repository 从Git存储库中提取特定版本文件 - Extract a particular version file from Git repository Git如何从克隆副本重建丢失的中央存储库 - Git how to rebuild lost central repository from cloned copies 如何从版本控制中排除文件/文件夹,但将其保留在Git的存储库中? - How to except a file/folder from versioning, but keep it in the repository in Git? 无论如何,有没有将一个特定的文件夹从SVN存储库克隆到git - Is there anyway to clone one particular folder from SVN repository to git 如何从当前现有的本地git存储库中最佳设置“中央” git存储库? - How to best set up a “central” git repository from a current existing local git repository? 从git存储库中恢复已删除的文件或文件夹 - Recover deleted file or folder from git repository 如何从git存储库中获取特定文件夹的特定提交,同时保持其余文件夹为最新? - How to get a specific commit of a particular folder from a git repository while keeping rest of the folders as latest?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM