3

I'm trying to push a local project to an empty GitHub repository (created only minutes ago), but I'm getting some errors.

I created my GitHub repository following the instructions here, and made my initial local git commit:

git add .
git commit -m "Initial commit" (this was successful)
git remote add origin https://github.com/[name]/[repo].git
git remote -v

Everything worked fine through that point, but next I tried this:

git push -u origin master

And got back the following stdout:

Counting objects: 8, done.
Delta compression using up to 8 threads.
error: garbage at end of loose object 'b3872d786a175232c101cca4bbd8f2cddde5622d'
fatal: loose object b3872d786a175232c101cca4bbd8f2cddde5622d (stored in .git/objects/b3/872d786a175232c101cca4bbd8f2cddde5622d) is corrupt
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
fatal: write error: Bad file descriptor
error: failed to push some refs to 'https://github.com/[name]/[repo].git'

This is the first time I've tried to push a local project to GitHub, and I can't seem to find a solution to my problem on GitHub's site or StackOverflow. Anybody know what to do here? Running OS X.

FelixSFD
  • 6,052
  • 10
  • 43
  • 117
nat5142
  • 485
  • 9
  • 21
  • What does `git fsck` say? – msanford Mar 06 '18 at 18:49
  • See https://stackoverflow.com/questions/4213598/corrupted-git-tree and https://stackoverflow.com/questions/4254389/git-corrupt-loose-object – msanford Mar 06 '18 at 18:51
  • @msanford `git fsck` says: `dangling blob 767a25f99a2436bcbda6d5ff16e8066722db01be` – nat5142 Mar 06 '18 at 19:04
  • Have you tried re initializing `git`? Remove the `.git` folder and start with the `git init` again. It has solved a similar issue. – myselfmiqdad Mar 06 '18 at 19:15
  • 1
    @miqdadamirali just did that a second ago. It didn't work in the past but I had to go up the directory tree to the parent directory and remove a .git from there too. Added a solution to the post. Thanks! – nat5142 Mar 06 '18 at 19:17
  • It sounds like you cloned a repo within another clone. It's not a good idea as you will include content from the child repo into the parent repo. – myselfmiqdad Mar 06 '18 at 19:25
  • It's generally a very bad sign if Git finds corrupted objects, as in, it means your disk drive (or SSD) is failing. However, if you're using a service like Dropbox or similar that dynamically changes files while your OS is using them, it's probably *that*. This is much less alarming and the cure is simple: don't put `.git` directories in Dropbox. Also, things like power failures (for non-battery-systems) or OS crashes can lead to these kinds of errors. – torek Mar 06 '18 at 19:30

1 Answers1

0

SOLUTION: Fairly simple fix for me - I just had to go up to the parent directory and rm -rf .git from there, too. Seems like a bit of a hack-y way to resolve it, and I'm still not quite sure what I did to cause the issue in the first place...

If anyone else runs into the same problem please be sure to pass it along here!

nat5142
  • 485
  • 9
  • 21