无法设置git ssh URL

时间:2016-09-19 18:08:40

标签: git github ssh

我正在尝试使用SSH在github上设置我的git repo的上游url。但它总是使用https网址。 我已经完成的步骤 -

  1. git clone git@github.com:pr4bh4sh/ios-with-swift.git并输出 $ git clone git@github.com:pr4bh4sh/ios-with-swift.git Cloning into 'ios-with-swift'... remote: Counting objects: 117, done. remote: Compressing objects: 100% (88/88), done. remote: Total 117 (delta 29), reused 103 (delta 19), pack-reused 0 Receiving objects: 100% (117/117), 467.42 KiB | 73.00 KiB/s, done. Resolving deltas: 100% (29/29), done. Checking connectivity... done.

  2. git remote -v输出

    master $ g remote -v origin https://github.com/pr4bh4sh/ios-with-swift.git (fetch) origin https://github.com/pr4bh4sh/ios-with-swift.git (push)

  3. git config remote.origin.url输出

    git@github.com:pr4bh4sh/ios-with-swift.git

  4. 我还尝试使用git remote set-url进行设置我可以看到,在配置中,它设置为ssh网址,但git remote -v显示https网址。

    它发生在MacOSX el Capitan上。我也尝试过Ubuntu 15.10上的步骤,它在那里工作正常。 Ubuntu有git v2.9.3,在Mac上我试过v2.9.3和v2.10.0

    我不想缓存身份验证,因此请不要建议将其作为解决方案。

2 个答案:

答案 0 :(得分:1)

这不是正常行为。这就是我认为发生的事情。

  • git clone https://github.com/pr4bh4sh/ios-with-swift.git
  • cd ios-with-swift
  • git clone git@github.com:pr4bh4sh/ios-with-swift.git
  • git remote -v

你克隆在你的克隆里面。如果您运行git status,您会看到:

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    ios-with-swift/

nothing added to commit but untracked files present (use "git add" to track)

这是另一种选择。

  • git clone https://github.com/pr4bh4sh/ios-with-swift.git
  • git clone git@github.com:pr4bh4sh/ios-with-swift.git
  • cd ios-with-swift
  • git remote -v

第二个克隆将失败并显示“致命:目标路径'ios-with-swift'已经存在且不是空目录”但可能已被遗漏或忽略。您将使用现有的https克隆。

如果不是这些,请同时显示.git/config~/.gitconfig

答案 1 :(得分:0)

您是否尝试过直接编辑var projects = from p in projectSet join lmp in LMProjects on p.ProjectID equals lmp.lmp_ProjectID where p.UserID == value select new { Project = p, LMProject = lmp }; 以使用.git/config网址?那是我的第一步。