Git:如何更新/签出远程原始主文件中的单个文件? [英] Git: How to update/checkout a single file from remote origin master?
问题描述
场景:
The scenario:
- 我在本地对单个文件进行一些更改并运行
git add
,git commit
和git push
- 推送到远程原始主存储库
- 我有另一个本地存储库,通过Capistrano通过远程存储库的remote_cache方法进行部署
- 现在我不想部署整个应用程序,只是更新/检出单个文件。
- I make some changes in a single file locally and run
git add
,git commit
andgit push
- The file is pushed to the remote origin master repository
- I have another local repository that is deployed via Capistrano with the "remote_cache" method from that remote repository
- Now I don't want to deploy the whole application but just update/checkout that single file.
请问,这是否可以用git ?我无法找到任何可行的工作,也无法找出答案。有了SVN,我只是做了 svn up file
和voila。
Please, is this somehow possible with git? I wasn't able to find anything that would work nor was I able to figure it out. With SVN I just did svn up file
and voila.
我会很乐意提供任何帮助,谢谢!
I'll be glad for any help, thanks!
推荐答案
Git不适用于单个文件。我不知道 remote_cache
设置,所以我不能对此发表评论。但是,在git中,您必须 clone
整个存储库,对文件进行更改,提交它(这是本地操作),然后推送更改背部。
Git doesn't work on individual files. I'm not aware of the remote_cache
setting so I can't comment on that. However, in git, you have to clone
the entire repository, make a change to a file(s), commit it (this is a local operation) and then push the changes back.
在您的设置中,您应该可以简单地从主存储库中调用它(称为M) pull
给你的卡皮斯特拉诺部署回购(称之为B)。我不明白你为什么会遇到问题。如果B完全不同并且你不想搞乱它,你可以将M作为 remote
添加到B,然后添加 cherry-pick
您感兴趣的特定提交(即您正在讨论的文件的更新)到B中。是否适合您?
In your setup, you should be able to simply pull
the changes from the master repository (call it M) to your capistrano deployed repo(call it B). I don't see why you're having the problem. If B is substantially different and you don't want to mess it up, you can add M as a remote
to B and then cherry-pick
the specific commits you're interested in (i.e. the update to the file you're talking about) into B. Would that work for you?
这篇关于Git:如何更新/签出远程原始主文件中的单个文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!