Przemek
Przemek

Reputation: 822

git cannot push to repository

I am trying to push into a repository, and it does exist and the link is correct. I am trying to force for it to ask me for username and password because I think something is wrong with that. This is the error:

λ git push origin master --force -v
Pushing to https://github.com/wojlive/liveandnow.git
remote: Repository not found.
fatal: repository 'https://github.com/wojlive/liveandnow.git/' not found

Upvotes: 3

Views: 2328

Answers (3)

Monte Hayward
Monte Hayward

Reputation: 477

This also works. Avoids the slash altogether.

git remote add origin [email protected]:YOUR_USERNAME/NEW_REPO.git

The result of this command can be seen in git config -l:

...
[email protected]:YOUR_USERNAME/NEW_REPO.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master

(If needed), create a new repo first: Is it possible to create a remote repo on GitHub from the CLI without opening browser?

Upvotes: 0

andybywire
andybywire

Reputation: 31

The trailing slash error (afaik) can't be removed just by entering the same origin again. In my case, unsuccessfully, I removed my remote, then added it again:

git remote remove origin  
git remote add origin https://github.com/andybywire/jekyll-foundation.git

But when I tried to push my changes, I still got the error:

fatal: unable to access 'https://github/andybywire/jekyll-foundation.git/': Could not resolve host: github

... trailing slash intact. After some further investigation I noticed that some of my other repos leave the .git off altogether:

git remote -v
origin  https://github.com/andybywire/content-first-prototyping (fetch)
origin  https://github.com/andybywire/content-first-prototyping (push) 

When I removed the .git from the first repo, the error went away entirely:

git remote remove origin  
git remote add origin https://github.com/andybywire/jekyll-foundation

This repo now allows me to do everything I would expect.

I don't know why, but I also went round and round with this (restarts, proxy settings, toggling wi-fi); this is what worked.

Upvotes: 3

Matt Clark
Matt Clark

Reputation: 28589

Try removing the trailing slash on your URI.

git remote remove origin
git remote add origin https://github.com/wojlive/liveandnow.git

Upvotes: 2

Related Questions