推送 Git 项目到本地目录
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6976459/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Push Git Project to Local Directory
提问by Aran
Don't know whether this is fully supported in Git would be excellent if it is as it could make things a lot easier, basically I have a project am working on in folder X and when I get it to a particular stage I want to push it to folder Y on my computer again.
不知道这是否在 Git 中得到完全支持会很好,因为它可以让事情变得更容易,基本上我有一个项目正在文件夹 X 中工作,当我将它推到特定阶段时,我想推送它再次到我电脑上的文件夹Y。
If this is possible great, what would be evener better is whether it is possible with either GitHub for Mac or Tower for Mac.
如果这可能很棒,那么更好的是是否可以使用 GitHub for Mac 或 Tower for Mac。
回答by dahlbyk
It is absolutely possible - what you probably want to do is create a "bare" git repository in folder Y (git init --bare
) and then add that file location as a remote:
这绝对有可能 - 您可能想要做的是在文件夹 Y ( git init --bare
) 中创建一个“裸” git 存储库,然后将该文件位置添加为远程:
git remote add Y file:///path/to/Y
I assume GitHub for Mac or Tower for Mac would handle this like any other remote.
我假设 GitHub for Mac 或 Tower for Mac 会像任何其他遥控器一样处理这个问题。
回答by manojlds
I would assume that you want to push to Y so that you can have a checked out folder of the "previous good" changes elsewhere. The answer from @dahlbyk suggests a bare repo. If you are going that way, you can ( and probably should) rather have a branch in the same repo.
我假设您想推送到 Y,以便您可以在其他地方拥有“以前好的”更改的签出文件夹。@dahlbyk 的回答暗示了一个裸仓库。如果你这样做,你可以(并且可能应该)宁愿在同一个 repo 中拥有一个分支。
Other than that, just clone the git repo in X into Y ( non-bare ) and either git pull
from Y or setup a remote like @dahlbyk from X and push to Y. Make sure receive.denyCurrentBranch
is set to false or a different branch from the branch you are pushing is checked out in Y
除此之外,只需将 X 中的 git repo 克隆到 Y(非裸)并git pull
从 Y 或从 X 设置像 @dahlbyk 这样的遥控器并推送到 Y。确保receive.denyCurrentBranch
设置为 false 或与您的分支不同的分支正在推动在 Y 中签出