Git:如何从Git中的服务器存储库中提取单个文件? [英] Git: How to pull a single file from a server repository in Git?

查看:284
本文介绍了Git:如何从Git中的服务器存储库中提取单个文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用运行Git的服务器的站点上工作.我正在使用Git进行部署(不是GitHub).这是在我参与之前使用 hook方法设置的,我指的是<一个href ="https://stackoverflow.com/questions/11245424/pull-single-file-on-server">这个问题,并在下面输入了命令,但是没有用.

I am working on a site with a server running Git. I am using Git for deployment (not GitHub). This was set up prior to my involvement using a hook method, and I referred to this question and entered the commands below, but it didn't work.

如何从服务器提取单个文件?例如,如果我想更新本地文件index.php? git pull index.php?

How do I pull a single file from the server? For instance, if I wanted to update my local file index.php? git pull index.php?

推荐答案

可以(在已部署的存储库中)进行操作:

It is possible to do (in the deployed repository):

git fetch
// git fetch will download all the recent changes, but it will not put it in your current checked out code (working area).

其次:

git checkout origin/master -- path/to/file
// git checkout <local repo name (default is origin)>/<branch name> -- path/to/file will checkout the particular file from the downloaded changes (origin/master).

这篇关于Git:如何从Git中的服务器存储库中提取单个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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