56

Since few time, I use Github for my projects and I have an issue when I want to push commits.

To beginning, I have forked a repository. Then I have cloned the fork (with command line git clone https://github.com/ ...) and, after doing modifications, I have committed with success (git commit -a).

After this, I have tried to push commits with command line git push but I obtain the following error:

fatal: could not read Username for 'https://github.com': No such file or directory

Have you got an idea to resolve this issue?

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
JohnDoe66
  • 855
  • 2
  • 11
  • 16

8 Answers8

62

What I had to do was:

git remote rm origin
git remote add origin 'git@github.com:username/repo.git'

Then, I was able to push my changes.

Rodrigo Medeiros
  • 7,814
  • 4
  • 43
  • 54
23

I tried following command and it worked for me

git push https://<username>:<password>@github.com/<username>/<repository-name>
Pulkit
  • 3,953
  • 6
  • 31
  • 55
21

Well I had the same problem - what annoys me to no end is that I don't have a clue why (edit: bug). I was pushing with https. Manually editing the config did not work for me (or doing a chkdsk as suggested in another answer). I ended up pushing with ssh - as in, replace:

https://github.com/USER/REPO.git

with

git@github.com:USER/REPO.git

after generating your keys

EDIT as to why : it is a bug in 1.8.5. See the report and a discussion with a way to workaround

Mr_and_Mrs_D
  • 32,208
  • 39
  • 178
  • 361
16

Since it's a bug from 1.8.5 version, if you don't want use SSH Key you can downgrade to 1.84 from here, or upgrade to higher version, 1.9.x, for example.

Ricardo
  • 7,921
  • 14
  • 64
  • 111
11

This seems to be a known bug in Git 1.8.5 on Windows. As described and reported by @Mr_and_Mrs_D:

https://groups.google.com/forum/#!msg/msysgit/s4dB8Nv9V4c/55-cGPdPYmAJ

Downgrading to 1.8.4 works for me. Please note you have to explicitly uninstall 1.8.5 first by running C:\Program Files (x86)\Git\unins000.exe as described here:

https://github.com/swcarpentry/bc/issues/234#issuecomment-33055444

I downloaded 1.8.4 here: https://msysgit.googlecode.com/files/Git-1.8.4-preview20130916.exe

AndyL
  • 14,302
  • 14
  • 43
  • 70
  • 2
    I've created an [unofficial fix release (1.8.5.4)](https://github.com/nevik/git/releases/tag/v1.8.5.4.msysgit.nevik.0) for people who want to or need to use a Git version newer than 1.8.4. This should serve as an intermediate solution until a new official release is made. – Nevik Rehnel Feb 09 '14 at 18:47
  • Quite disappointing, if the notoriously most basic use case: git clone... + git add... + git commit + git push does not work. None of the hints in the answers above worked for me, but the final workaround was to use git gui, which did the work immediately. It asked for username and password, and performed push as expected. What a wasted time with this terrible tool! – Palo Apr 03 '16 at 13:13
3

In my case, I update Git to version 1.9 and this issue is fixed.

During push/commit, the Git Bash will ask for Github's account & password.

Dio Phung
  • 5,944
  • 5
  • 37
  • 55
0

I used git-credential-winstore before. When I reinstalled my Windows, that error popep up. I resolve the issue by downloading git-credential-winstore again in my PATH.

Kevin Tong
  • 3,626
  • 1
  • 17
  • 12
0

I had this issue also using GitHub from Visual Studio. I went to Team Explorer->Manage Connections->Connect a Project then Select Github which re-authenticated me in the web browser. I was then able to push my changes.

Mustafa
  • 176
  • 3
  • 13