Wednesday, 1 April 2020

Using GitHub from Xcode and Mac OS Command Prompt

Introduction

I have the front end app developed in Xcode and the backend logic developed in NodeJS.  Therefore I will need to manage 2 independent repositories.

Using GitHub from Xcode 11

If you Xcode project is using local Git, you can create new remote GitHub repository directly in Xcode.  Follow this link.

Using GitHub from Mac OS Command Prompt

You need to create an empty private repository in GitHub manually first followed by pushing it from command prompt.
  1. Create Repository in GitHub manually.  Set it to private.
  2. Copy the clone url.  Example: https://github.com/username/project_name.git
  3. On Mac, open the command prompt and go to the project folder.  Ensure that the git user has permission to the repository.  Check the user using git config user.name
  4. Set the origin URL to the new repository.  git remote set-url origin https://github.com/username/project_name.git
  5. If the local git repository doesn't have any existing remote.  You can use add.  git remote add origin https://github.com/username/project_name.git
  6. Push to remote.  git push -u origin master
  7. Omit the -u parameter for subsequent push.
If you see this error, you can clear your credential first.
$ git push origin master
remote: Repository not found.
fatal: repository 'https://github.com/username/project_name.git/' not found

No comments:

Post a comment