从一个仓库推送到另一个仓库 - Git
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16656684/
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 from one repo to another - Git
提问by moesef
I have a repo on my local computer. I want to develop and make changes in a branch on my local repo and then push these changes for testing to a repo on a server that I can ssh into. How do I do this? I have never pushed/pulled from the local to the server, only pulled down through SSH from my bitbucket account to either my local computer or remote server.
我的本地计算机上有一个仓库。我想在本地存储库的分支中进行开发和更改,然后将这些更改推送到我可以通过 ssh 进入的服务器上的存储库进行测试。我该怎么做呢?我从来没有从本地推/拉到服务器,只是通过 SSH 从我的 bitbucket 帐户下拉到我的本地计算机或远程服务器。
Thanks, Mo
谢谢,莫
回答by Klas Mellbourn
You can create a repo on the server by logging in to it, and do a git init --bare
.
您可以通过登录在服务器上创建一个 repo,然后执行git init --bare
.
Then on you local computer you
然后在您的本地计算机上
git remote add serverrepo <url to server repo>
Now you can push and pull to the serverrepo, and to origin (bitbucket?).
现在您可以推送和拉取到 serverrepo 和源(bitbucket?)。
You can push your branch to just the serverrepo if you wish:
如果您愿意,您可以将您的分支推送到 serverrepo:
git push -u serverrepo branchname
If you need to "publish" the repo on the server somehow, you can follow this guide.
如果您需要以某种方式在服务器上“发布”repo,您可以按照本指南进行操作。
回答by mhenry1384
If you want to avoid the command line and are using Atlassian SourceTree do Repository->Add Remote on the source repository and then you can push your changes to the destination.
如果您想避免命令行并使用 Atlassian SourceTree 在源存储库上执行 Repository->Add Remote,然后您可以将更改推送到目标。