【问题标题】:Added BitBucket repo as remote on GitHub在 GitHub 上将 BitBucket 存储库添加为远程
【发布时间】:2013-12-03 15:01:03
【问题描述】:

我刚刚在 Ubuntu 上安装了 git,现在我想在 BitBucket 中处理我的 repo。我对如何做到这一点有点困惑。我不能执行以下操作:

git remote add BitBucketRepo git@bitbucket.org:dir/file.git

因为它返回以下错误:

fatal: Not a git repository (or any of the parent directories): .git

它显然指向一个 git repo,那为什么要骗我呢?

另外,值得注意的是,我正在使用 SSH,并且我已成功将我的 GitHub 帐户与我的计算机配对。

【问题讨论】:

    标签: linux git github bitbucket git-remote


    【解决方案1】:

    您需要从本地 git 存储库(您已在其中运行 git initgit clone 的目录)运行此命令 - 否则 git remote 不知道您要为哪个本地存储库添加远程。

    它应该像cd my-local-dir 一样简单,其中my-local-dir 是包含本地(克隆)git 存储库的目录。

    如果您还没有本地可用的 repo:

    git clone git@github.com:...etc... my-local-dir
    cd my-local-dir
    git remote add ButbucketRepo git@bitbucket.org...
    git push -u ButbucketRepo master
    

    这会将您的代码从 Github 克隆到 my-local-dir 目录,将您的 BitBucket 存储库添加为远程存储库,将您的代码推送到 Bitbucket 并设置本地 master 分支以跟踪 BitBucket 远程的 master 分支。

    跟踪意味着涉及git push 等远程的命令将自动使用 BitBucket 远程的master 分支。如果您不想要这种行为,请跳过 -u 选项。

    【讨论】:

    • 出色的答案。很简单,但我是新手。谢谢!
    猜你喜欢
    • 2021-10-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-11
    • 2015-02-27
    • 2018-01-06
    • 2016-07-25
    • 2016-03-10
    相关资源
    最近更新 更多