Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git commit on Windows (Cygwin) is broken.

Tags:

git

cygwin

I've got a Cygwin install on Windows 7. Git was working great up until a few days ago, when commits just stopped working. Here's a log of a brand new repo:

wt@CO /cygdrive/u/Projects
$ mkdir Temp

wt@CO /cygdrive/u/Projects
$ cd Temp/

wt@CO /cygdrive/u/Projects/Temp
$ touch Hello.txt

wt@CO /cygdrive/u/Projects/Temp
$ git init
Initialized empty Git repository in /cygdrive/u/Projects/Temp/.git/

wt@CO /cygdrive/u/Projects/Temp
$ git add .

wt@CO /cygdrive/u/Projects/Temp
$ git commit -m "hi"
error: invalid object 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 for 'Hello
.txt'
error: Error building trees

I've Google-ed the hell out of it to no avail. What's going on here?

like image 871
Weston Avatar asked Jul 28 '11 23:07

Weston


3 Answers

Cygwin git appears to be creating new object files using a "create-temp-file-then-hardlink-to-destination" method. I think the hard-linking is confusing for cygwin!

Bottom line: solved using:

git config --add "core.createobject" rename

(My setup is Cygwin git, working on a .git directory over samba)

like image 200
PeteC Avatar answered Oct 22 '22 18:10

PeteC


The problem here is that Git's default method of creating object files just plain doesn't work on Windows shared drives, and (unlike Git for Windows or msysgit), Cygwin's Git has just been using that default.

Until today – I'm the Git maintainer for Cygwin – and I've just rebuilt it to use a different method that does work on shared drives (it has other disadvantages, but there's not a lot we can do about that). If you run Cygwin's setup-x86[_64].exe again and download the latest version of Git (v2.4.5-3 or later), you should find everything works again.

(The new Git build has only just been uploaded, so it may take a little while to reach all the mirrors, but I think that's at most 24 hours, and many mirrors are quicker than that.)

like image 45
me_and Avatar answered Oct 22 '22 19:10

me_and


Use Git for Windows instead. Cygwin's Git started going downhill a while back. My team and I had more and more problems with it as time went on and finally just switched. With a full port of Git to Windows (the msysgit/Git for Windows project) available, why put up with the annoyances and outright brokenness that comes with Cygwin Git? We haven't had a single issue since switching.

like image 21
Ryan Stewart Avatar answered Oct 22 '22 19:10

Ryan Stewart