pr4bh4sh pr4bh4sh - 1 month ago 5x
Git Question

Not able to set git ssh URL

I'm trying set upstream url of a git repo of mine at github with SSH. But it always uses https url.
Steps I have done-

  1. git clone
    and output

    $ git clone 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
    output is

    master $ g remote -v origin (fetch)
    origin (push)

  3. git config remote.origin.url

I have also tried setting it with
git remote set-url
I can see that in config it's set to ssh url but
git remote -v

It happening on MacOSX el Capitan. I have also tried the steps on Ubuntu 15.10 and it works fine there.
Ubuntu has git v2.9.3 and on Mac I have tried with v2.9.3 and v2.10.0

I don't want to cache the authentication so please don't suggest that as solution.


This is not normal behavior. Here's what I think happened.

  • git clone
  • cd ios-with-swift
  • git clone
  • git remote -v

You cloned inside your clone. If you run git status you will see this:

$ 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)


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

Here's an alternative.

  • git clone
  • git clone
  • cd ios-with-swift
  • git remote -v

The second clone will fail with "fatal: destination path 'ios-with-swift' already exists and is not an empty directory" but that may have been missed or ignored. You're left with your existing https clone.

If it's none of those, please show both .git/config and ~/.gitconfig.