如何从Git的中央存储库更新特定的文件夹/文件? [英] How to update particular folder/file from central repository in Git?

查看:350
本文介绍了如何从Git的中央存储库更新特定的文件夹/文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Git中单独更新文件夹或文件?我是从中央存储库克隆的,只希望更新特定的文件夹/文件.

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.

推荐答案

您可以使用git fetch更新本地克隆中的对象,然后可以git checkout这些特定文件.

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

例如-如果您的遥控器称为Origin,而您只想从master分支更新main.c,则可以执行以下操作:

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.

这篇关于如何从Git的中央存储库更新特定的文件夹/文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆