1

I am using Xcode version 12.5 and want to push a demo app to GitHub.

Though I have used GitHub to upload iOS apps in the past; it was a while ago and I needed a mind refresher so I followed these tutorials: How To Use GitHub with Xcode 11 and How to upload Xcode project to GitHub (Working with Git), hoping it would be OK for my use case.

Also taking a look here to review my GitHub knowledge.

But when I try to push my project from Xcode I keep getting this message:

The given URL 'git+ssh://git@github.com:me/MyRepo.git' is invalid.

Provide a valid URL and try again.

although my repository is created. What am I missing?

....... Some more information follows.

Here is what happens when I try a pull:

MacBook-Air$ git pull origin master
hint: Pulling without specifying how to reconcile     divergent branches is
hint: discouraged. You can squelch this message by    running one of the following
hint: commands sometime before your next pull:
hint: 
hint:   git config pull.rebase false  # merge (the    default strategy)
hint:   git config pull.rebase true   # rebase
hint:   git config pull.ff only       # fast-forward    only
hint: 
hint: You can replace "git config" with "git config     --global" to set a default
hint: preference for all repositories. You can also     pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override    the configured default per
hint: invocation.
fatal: couldn't find remote ref master
MacBook-Air$ 
Michel
  • 10,303
  • 17
  • 82
  • 179
  • Try `git remote set-url origin git@github.com: com:me/MyRepo.git` – aheze Aug 23 '21 at 04:37
  • This worked for me a few minutes ago, `git remote add origin https://username:access-token@github.com/username/repo.git` – goatofanerd Aug 23 '21 at 04:42
  • I tried to follow these advices, one after the other. In both cases I get this new message: "The local repository is out of date. Make sure all changes have been pulled from the remote repository and try again." – Michel Aug 23 '21 at 05:03
  • Since the local repository is actually the only content I have, I am not sure how it can be out of date. – Michel Aug 23 '21 at 05:10

1 Answers1

1

git+ssh:// might not be correctly interpreted by XCode, while a regular SSH URL (git@github.com:me/myRepo) or HTTPS one would work.

If you are using HHTPS, don't forget to activate git config credential.helper (you should see osxkeychain) in order to cache your PAT(Personal Access Token), instead of putting it in clear text in your URL.

Finally, do a git fetch and see what git status returns.
And git push, or, if you are sure your local history is the right one, git push --force (assuming you are the only one working on that repository).

Another approach (with Git 2.6+, Sep. 2015):

If you care about the remote (GitHub) history, then:

git config --global pull.rebase true
git config --global rebase.autostash true
git pull

That will automatically replay your local commits on top of the updated (fetched) remote tracking branch origin/<yourBranch>

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks. You mention "git config credential.helper". Is this a command to run in the terminal? – Michel Aug 23 '21 at 09:01
  • I have run the command and get osxkeychain. But for the rest, trying to follow your suggestions, I still get the message mentioned in a previous comment: "The local repository is out of date. Make sure all changes have been pulled from the remote repository and try again." – Michel Aug 23 '21 at 09:22
  • @Michel OK. What happen when you pull? – VonC Aug 23 '21 at 10:03
  • I added some information to the post so you can see the result of a pool. I am not using GitHub very often and it seems like I am missing a few important details in terms of configuration. – Michel Aug 23 '21 at 14:06
  • 1
    @Michel If you care about the remote (GitHub) history, then: `git ocnfig --global pull.rebase true`, `git config --global rebase.autostash true`. And finally `git pull`. – VonC Aug 23 '21 at 14:49
  • I followed your tips as well as corrected a mistake on my part (I was using a wrong branch name) and it finally works. Thanks a lot. I accepted your answer, though in fact as much as the answer it is the comments I want to accept. – Michel Aug 24 '21 at 01:41
  • @Michel Well done. I have included the comment in the answer for more visibility. – VonC Aug 24 '21 at 05:29