36

Why won't my git push? I created the repository and I keep getting this message:

C:\Users\petey_000\rails_projects\first_app>git push -u github master
Username for 'https://github.com': ***@gmail.com
Password for 'https://***@gmail.com@github.com':
remote: Repository not found.
fatal: repository 'https://github.com/pete/first_app.git/' not found
GGMG-he-him
  • 394
  • 1
  • 7
  • 26
Peter Arevalo
  • 373
  • 1
  • 3
  • 5

13 Answers13

45

Your username shouldn't be an email address, but your GitHub user account: pete.
And your password should be your GitHub account password (2014).

Update 2021: your password should be (since Aug. 2021) a PAT (Personal Access Token).

You actually can set your username directly in the remote url, in order for Git to request only your password:

cd C:\Users\petey_000\rails_projects\first_app
git remote set-url origin https://pete@github.com/pete/first_app

And you need to create the fist_app repo on GitHub first: make sure to create it completely empty, or, if you create it with an initial commit (including a README.md, a license file and a .gitignore file), then do a git pull first, before making your git push.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • thanks, that fixed it, I thought I had the repository set up, but did not. I was still able to use my email address to push though, but thanks for the tip, i see now that is dumb to type the entire thing out – Peter Arevalo Aug 20 '14 at 17:36
  • Just to reiterate the point: wheather you write `first_app.git/` or `first_app/`, git will fail with `ERROR: Repository not found.` because of the trailing slash. Spell it either as `first_app` or `first_app.git` without the slash and you're good to go... – ihadanny Sep 15 '14 at 10:13
  • 3
    I have the same error message, however when viewing the repository name with `git remote -v` I don't see a trailing slash, but it's there in the error message. Funny thing is `git fetch` works fine but `git push` fails with `repository 'https://github.com/_/_.git/' not found` – Stefan L Jul 01 '15 at 09:38
  • @StefanL can you try with `git remote set-url origin https://github.com/_/_`? Also make sure the case (uppercase, lowercase) is respected. – VonC Jul 01 '15 at 10:27
  • 1
    @VonC I did actually, set-url didn't help. But I in my case I found out I don't have write permissions on the repository, think that's the root cause, only logical to get an error message then but would expect another one. – Stefan L Jul 01 '15 at 11:12
  • 1
    For future reference, note that even when everything is set up correctly, if you don't have permissions to push you will get this exact error. – pmoleri May 05 '20 at 18:15
34

If this problem comes on a Windows machine, do the following.

  • Go to Credential Manager
  • Go to Windows Credentials
  • Delete the entries under Generic Credentials
  • Try connecting again. This time, it should prompt you for the correct username and password.

control panel

enter image description here

Gaurav
  • 872
  • 12
  • 28
  • This was the answer that worked for me. Using git version 2.34.1.windows.1 on Windows 10. My problem was that I could do all git operations with the GitHub Desktop client, but doing them via the command line would also result in a "fatal: repo not found" error. After deleting all the git credentials under Windows Credentials, I can do both now. – InvalidBrainException Dec 20 '21 at 18:36
13

Three things:

  1. Your GitHub username is not an email address. It should be a username (like "sethvargo")
  2. You have a trailing slash on your repo name:

    $ git remote rm origin
    $ git remote add origin https://github.com/pete/first_app.git
    
  3. You need to create the first_app repo. I looked at "pete" on GitHub, and I do not see the repository. You must first create the remote repository before you may push.

sethvargo
  • 26,739
  • 10
  • 86
  • 156
  • 2
    This is *exactly* my answer, except `remote set-url` avoid the `remote rm` + `remote add`... – VonC Aug 17 '14 at 05:44
  • 2
    Interesting. I didn't know about `remote set-url`, thanks! And your answer does not mention the trailing slash, which I think is the _real_ problem here. Although there is not enough information to be sure. – sethvargo Aug 18 '14 at 12:43
  • Probably the trailing slash is not the _real problem_ here, I just got this exact same issue with trailing slash an everything and it turned out that I didn't have push permissions. The trailing slash is added to the error message even when not present in the push url. – pmoleri May 05 '20 at 18:19
6

In my case, it was different! But I think sharing my experience might help someone!

In MAC, the 'keychain access' has saved my previous 'Github' password. I was trying with a new GitHub repository, and it never worked. When I removed the old GitHub password from 'keychain access' from my MAC machine it worked! I hope it helps someone.

Anand
  • 61
  • 1
  • 1
  • You were probably getting a different error message in your case? – tomsv Sep 12 '20 at 15:49
  • This worked for me on my Mac. Launchpad > Keychain > Search for "Github" > Edit Username and Access Token (in Password space) to your new Github account. I couldn't delete the entry due to the Mac being owned/maintained by my work organization, but I could edit it. As soon as I replaced the account details and ran the git clone command again in VSCode, it worked. Mind you, password auth has been depreciated since Aug 2021. So you need to use an access token anyway which you generate from Github.com user Settings Page in place of a Password. – pythonInRelay Jul 13 '22 at 10:03
4

Please find below the working solution for Windows: It worked for me. 1 Open Control Panel from the Start menu. 2 Select User Accounts. 3 Select the "Credential Manager". 4 Click on "Manage Windows Credentials". 5 Delete any credentials related to Git or GitHub. 6 Once you deleted all then try to clone again.

Archana Kamath
  • 426
  • 4
  • 4
  • 1
    Thank you! I have two github account, first time I logged it works because the git client requested for my credentials, when I tried to upload a different project with the another github account I saw the message "fatal: repository 'https://github.com/TddfaLucfasfd' not found". I follow your instructions and tried again so the git client requested the new credentials. – Luis Armando Aug 21 '20 at 02:40
3

I have solved the same issue by giving the read permision from github account.

  1. Go to github account go the user write permission.
  2. When we clone the code we need read permission.
  3. When we need to push the code we use write permission so you need to give write permission.
Allan
  • 12,117
  • 3
  • 27
  • 51
bharat udasi
  • 133
  • 7
3

This answer is a bit late but I hope it helps someone out there all the same.

In my case, it was because the repository had been moved. I recloned the project and everything became alright afterwards. A better alternative would have been to re-initialize git.

I hope this helps.. Merry coding!

Taslim Oseni
  • 6,086
  • 10
  • 44
  • 69
3

Late 2021 update

GitHub changed authentication flow some time in August of 2021. I was having the same problem and managed to push a new project into GitHub by following these steps:

echo "# REPO_NAME" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://USERNAME:ACCESS_TOKEN@github.com/USERNAME/REPO_NAME.git
git push -u origin main

The origin URL must have the username followed by an access token.

You can generate the ACCESS_TOKEN by going to Github > Settings > Developer Settings > Personal access tokens > Generate new token. Give it a name and make sure you select Repo in Select Scopes.

Personally I think this is overkill. Tokens expire and now I have to manage tokens for each project that I work on. Maybe there is an easier way, I don't know but I hope so. My VS Code is already authenticated with Github, why complicate things. Maybe someone can show a easier way to go about it.

Caio Mar
  • 2,344
  • 5
  • 31
  • 37
2

Make sure your git username and password is correct. In my case, it gave error when the username and password(especially the GIT TOKEN) was not correct.

Avinash Thombre
  • 194
  • 1
  • 5
1

I faced exactly the same error message. When I run ls -a, I found out that .git was missing (surely I deleted it by inadvertence in previous days). As what I have locally is the same as on the Github repository, I simply removed my local "folder" and cloned the remote one again. After that, everything worked fine for me:

rm -rf my_project
git clone https://github.com/begueradj/my_project.git
Billal Begueradj
  • 20,717
  • 43
  • 112
  • 130
0

Also, be sure, that two-factor authentication is off, otherwise use personal access tokens

Details here : Can I use GitHub's 2-Factor Authentication with TortoiseGit?

Community
  • 1
  • 1
Nigrimmist
  • 10,289
  • 4
  • 52
  • 53
0

I tried pretty much everything suggested in the answers above. Unfortunately, nothing worked. Then I signout out of my Github account on VS Code and signed in again. Added the remote origin with the following command.

git remote add origin https://github.com/pete/first_app.git

And it was working.

Samiul Lesum
  • 238
  • 3
  • 10
0

signout from your account in vs code and relogin

Ahmed Raza
  • 401
  • 4
  • 6