2016-06-08 72 views
1

我有一个项目,我从公共回购克隆到我调整并推送到Heroku的PC上。
我现在希望将我调整过的代码作为备份推送到BitBucket。Git来源于bitbucket

$ git status 
On branch master 
Your branch is ahead of 'origin/master' by 13 commits. 
    (use "git push" to publish your local commits) 

nothing to commit, working directory clean 

$ git remote 
heroku 
origin 

当我尝试用加到位桶的命令,它的错误:

fatal: remote origin already exists 

也就是说,后:

$ git remote add origin [email protected]:me/myproject.git 
$ git push -u origin --all # pushes up the repo and its refs for the first time 
$ git push origin --tags # pushes up any tags 

我会纠正以为我只需要更新“origin “指向BitBucket而不是原始的回购?

回答

1

Would I correct in thinking I just have to update "origin" to point to BitBucket instead of the original repo?

作为备份更直观只需添加一个新的远程

git remote add bitbucket /url/to/your/bitbucket/repo 
git push -u bitbucket --all 

如果你真的想改变远程“origin”(因为“heroku”就足够了),那么它会得到:

git remote set-url origin /url/to/your/bitbucket/repo 

不需要一个git分支命令,push会为你创建bitbucket远程分支。

0

因此,您不想再次使用相同的名称添加远程设备,该设备将始终失败。 origin作为一个名称除了它是约定外没有任何内在特殊之处。

您的当前分支设置为跟踪远程origin/master。如果你想能够直接推送到你的bitbucket作为一个新的回购。

你可以添加一些远程命名的bitbucket非常简单。

git remote add bucket <repo-url> 

然后你就可以更新当前分支能够跟踪斗主分支

git branch -u bucket/master 

所以,当你运行:

git push 

它会直接把你的改变到位桶。

+0

我添加了我的新远程,然后尝试git分支-u桶/主但是收到以下错误:“错误:请求的上游分支”桶/主“不存在” – Dercni

+0

好了,因为分支已不存在,在你第一次推动它之前,没有什么可以跟踪的 –