David
David

Reputation: 276

remote: Repository not found error in mac terminal

I am new to git. I have a private repo and now I want to push the changes of my local to remote repo. However, I get an error:

remote: Repository not found.
fatal: repository 'https://github.com/co-csp/csm.git/' not found

What might cause these error and please help me how to solve it, I am using Mac terminal. My username is john2 in github profile git config user.name and git config user.username both gives john2 so username seems correct...

Upvotes: 11

Views: 42221

Answers (6)

Ayoub BOUMZEBRA
Ayoub BOUMZEBRA

Reputation: 4993

Use SSH URL Instead of HTTPS:

If you were using an HTTPS URL initially, try switching to the SSH URL. Update the remote URL using the following command:

git remote set-url origin [email protected]:username/repo.git

Replace username with your GitHub username and repo.git with your repository name

Upvotes: 0

I had the same problem

The error was that I had store my personal credentials of github and when tried to made git clone in the terminal automatically set this old credential.

  1. You need to clean your old github credential, logout your github account in VS and to make sure (in Mac -> Keychain Access delete the github crendential)

  2. Setup your personal token in github

https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token

  1. Login with the new token

    $ git clone https://github.com/USERNAME/REPO.git
    Username: YOUR_USERNAME
    Password: YOUR_TOKEN```
    
    

and done!

Upvotes: 1

Shapon Pal
Shapon Pal

Reputation: 1146

Updating credentials from the macOS Keychain

Method 1: Updating your credentials via Keychain Access

  1. Click on the Spotlight icon (magnifying glass) on the right side of the menu bar. Type Keychain access then press the Enter key to launch the app.
  2. In Keychain Access, search for github.com.
  3. Find the "internet password" entry for github.com.
  4. Edit or delete the entry accordingly.

Method 2: Deleting your credentials via the command line

Through the command line, you can use the credential helper directly to erase the keychain entry.

$ git credential-osxkeychain erase
host=github.com
protocol=https
> [Press Return]

Source: https://docs.github.com/en/get-started/getting-started-with-git/updating-credentials-from-the-macos-keychain#updating-your-credentials-via-keychain-access

Upvotes: 5

rslj
rslj

Reputation: 380

If you are working with a private repository, do the following:

  1. git remote rm origin
  2. git remote add origin https://[email protected]/co-csp/csm.git
  3. git clone https://[email protected]/co-csp/csm.git

This should prompt you to type in the GitHub password and should look like this.

Cloning into 'csm'... Password for 'https://[email protected]':

Upvotes: 7

rewire
rewire

Reputation: 81

There are two possibilities why the Repository not found error occurs:

  1. The remote repository does not exist. If you have already set up the remote URL, display it by typing $ git remote -v and check that you spelled everything correctly. If you haven't added the remote URL yet, try $ git remote add origin [URL] to do so. Also make sure you can find the repo on github; maybe the owner deleted or renamed it. To locally update the URL to your remote repository, type $ git remote set-url origin [new-URL]. After that, type $ git remote show origin to check whether git can find the remote repo now.

  2. The remote repository is private and you don't have access. If the repository is private and you didn't authenticate correctly, git will give you the Repository not found error even if your remote repository URL is correct. Generally, you can authenticate by using either SSH keys or HTTPS. Using HTTPS, git should normally prompt you for your credentials when it needs them. If it doesn't, try removing your local reference to the remote repo by typing $ git remote rm origin and re-add it using $ git remote add origin [URL]. I personally prefer using SSH authentication with public and private keys, since it doesn't necessarily require any passwords. You might check out this link to set up SSH authentication for your GitHub, or simply google for it.

Upvotes: 2

atomNULL
atomNULL

Reputation: 269

You have two options here. One option is to use git clone, the other options is git init.

Option 1: Use git clone. In a new empty folder put the following command: git clone https://github.com/co-csp/csm.git. You are ready to go.

Option 2: In the project folder, type git init. This will initiate an empty new repository. It will create a .git folder inside. Go to this folder by typing cd .git. Open the config file with your favourite editor (mine is vim). You will see the following there:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true

Underneath, append the following:

[remote "origin"]
        url = https://github.com/co-csp/csm.git
        fetch = +refs/heads/*:refs/remotes/origin/*

Upvotes: 0

Related Questions