【问题标题】:Problems adding git remote repository添加 git 远程存储库的问题
【发布时间】:2011-06-29 12:52:35
【问题描述】:

我在将远程存储库添加到本地存储库时遇到问题。我第一次尝试使用 Tower 来添加我的本地存储库,但是在添加远程存储库时,它只是说添加 URL。它没有说明这个 URL 的任何内容。是否应该包括 ssh:// 我的用户名等。

所以我找到了this article 并严格按照它,直到添加了一个远程存储库。它失败了。有人可以帮忙吗?

Kasper-Srensens-MacBook-Pro:~ Kasper$ git remote add origin ssh://kasperso@kaspersorensen.com:2227/www/mechatronicscluster/wp-content.git fatal: Not a git repository (or any of the parent directories): .git Kasper-Srensens-MacBook-Pro:~ Kasper$

【问题讨论】:

    标签: git


    【解决方案1】:

    您必须在 git 存储库中才能为该特定存储库添加远程。 使用cd 更改当前目录。

    【讨论】:

    • 感谢您的回复。我试图 cd 进入 lcoal git,运行相同的命令仍然出现错误。 Kasper-Srensens-MacBook-Pro:wp-content Kasper$ git status # On branch master nothing to commit (working directory clean) Kasper-Srensens-MacBook-Pro:wp-content Kasper$ git remote add origin ssh://kasperso@kaspersorensen.com:2227/www/mechatronicscluster/wp-content.git fatal: remote origin already exists. Kasper-Srensens-MacBook-Pro:wp-content Kasper$
    • 那么我猜遥控器已经添加了。输入 cat .git/config 以查看您的 repo 的配置文件并检查远程是否存在。
    • 是的,它看起来像。但是现在我又遇到了另一个问题,我无法将本地存储库推送到远程。在下面的评论中查看我的终端输出。
    【解决方案2】:

    注意:如果你必须在那个确切的 git 存储库之外执行该命令,你 can set the GIT_DIR environment variable:

    (
        GIT_DIR=/somewhere/else/.git; export GIT_DIR
        git <command>...
    )
    

    或者只是在你的命令中使用 --git-dir 选项

        git --git-dir=/somewhere/else/.git <command>...
    

    这适用于不需要位于工作树(已签出的 Git 存储库)中的命令。 git remote add 符合这个标准。

    【讨论】:

    • 谢谢。有用的信息,正如您从我上面的评论中看到的那样,即使我在本地 git repo 中,我也没有运气。
    • @Kasper:“git remote -v”显示了什么?很可能已经定义了远程“原点”,但不是您想要的地址。您可以将您的地址添加为名为“其他”而不是“来源”的远程地址,然后从那里开始。
    • 谢谢,我又试了一遍,但好像总是撞墙Kasper-Srensens-MacBook-Pro:wp-content Kasper$ git remote -vorigin ssh://kasperso@kaspersorensen.com:2227/www/mechatronicscluster/wp-content.git (fetch) origin ssh://kasperso@kaspersorensen.com:2227/www/mechatronicscluster/wp-content.git (push) Kasper-Srensens-MacBook-Pro:wp-content Kasper$ git push origin master ssh: connect to host kaspersorensen.com port 2227: Operation timed out fatal: The remote end hung up unexpectedly Kasper-Srensens-MacBook-Pro:wp-content Kasper$
    • @Kasper:用stackoverflow.com/questions/922210/…检查你的ssh配置
    【解决方案3】:

    使用例如 bitbucket,您可以通过他们的 Web 服务轻松创建远程分支,然后在 Tower 中获取远程存储库(它将添加新的分支图标)

    【讨论】:

      猜你喜欢
      • 2015-01-18
      • 1970-01-01
      • 2011-06-05
      • 2011-12-27
      • 2015-12-16
      • 1970-01-01
      • 1970-01-01
      • 2013-09-05
      • 1970-01-01
      相关资源
      最近更新 更多