Git Initial Push Bad File Descriptor Error - linux

I am new to git and have been following various tutorials on setting up a centralized git server. For the past few days, I have been having trouble with the following error message:
Counting objects: 59, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (59/59), done.
Writing objects: 100% (59/59), 525.33 KiB | 0 bytes/s, done.
Total 59 (delta 15), reused 0 (delta 0)
remote: fatal: failed to read object 24e3826fe4be7dbaddbfcd698e943b5b8f9598ec : Bad file descriptor
error: unpack failed: unpack-objects abnormal exit
To ssh://git#[server url]/volume1/git/[project name]
! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to 'ssh://git#[server url]/volume1/git/[project name]'
Initially, I used GitEye on my client side to manage git repository, but I encountered the problem when I tried to push my first commit to my linux server. So I played around with the permission and set the ownership of the whole git directory recursively to user "git". Nothing works. So I tried cloning a bare repository from the server and then try the push, but that didn't work either...returning me with unpacker error.
So I switch my software to Git Extensions and also trying the push on Git Bash...still the same error. Oh, forgot to mention that in the process, I deleted my local and remote git repository various times.
While one may argue that this may be a duplicate of git push over sshfs failing with “error when closing sha1 file: Bad file descriptor”, but I don't use sshfs and I am running Windows on my client side.
This may be a duplicate of Git push error - fatal: file '' write error: Bad file descriptor, but the push never works before.
UPDATE:
With mentioning about the version, I wonder if the version mismatch between the server and the client is the source of the problem. So I downgrade my client git version from 1.9.4 to 1.8.4.msysgit.0, but still found the problem after deleting and recreating a new git repository.
What interesting though is that I also tried to copy manually the git repository from the client to the server and do a git status on the remote side. As a result, I encounter the bad file descriptor, but that error didn't appear on the client side.

I found the source of the problems. I tried to do a first commit on my remote side and I got "not a valid object" error. Thus, I have a bad git build on my remote side. Thanks for your guidance. It points me the right path to look.
Now I have to figure how to get a newer (or different) version of git for my remote platform without having to use ipkg.

Related

Why is my local project not being pushed to github repository?

I have a node app in my local machine, which works totally fine on localhost, i have tried to push the code to github repository, if it didn't work, i created new repos and tried again
I even adopted both methods to push using git bash:
using ssh and http
In my .gitignore file i have written node_modules/
But every time i get the same error message and code is not pushed to my github repo, the error is :
$ git push -u bb4 main
Enter passphrase for key '<path for ssh key>':
Enumerating objects: 2484, done.
Counting objects: 100% (2484/2484), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2457/2457), done.
Writing objects: 100% (2484/2484), 272.37 MiB | 679.00 KiB/s, done.
Total 2484 (delta 492), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (492/492), done.
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 7eaa2fe7b701a22ea9b13333b122831363593fb6a0ce25c557df3aa90fa29f9e
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File mongod.pdb is 367.00 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File mongos.pdb is 247.35 MB; this exceeds GitHub's file size limit of 100.00 MB
To github.com:<username>/<reponame>.git
! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'github.com:ritish73/bb4.git'
it shows two too large files mongod.pdb and mongos.pdb, where are these files coming from , i thought they might be in node_modules but i have already added that to .gitignore file.
There is also a .git(hidden) directory inside my project directory which is a local repo of the project handled by vscode itself, Could it be causing some issue? (though i did add this to .gitignore too, still didn't work).
What could be the problem here? Happy to hear your thoughts and resolve this error. This is my directory structure where i run git bash.
Clearly github doesnt allow too big files, you got that right.
You also added node_modules to your .gitignore which is good, too.
You shouldnt add your .git directory, tho, since this is created when you ran git init - this directory is essential for your local git repository.
I guess that you added your node_modules in some previous commit, thus it is added in your history, meaning that the resulting diffs would be pushed to the repository.
You would have to alter these commits to exclude node_modules but for the sake of simplicity it would just create a new git repository (by deleting .git and run git init again)
There seems to be so called Github hook to deny your push, see [remote rejected] main -> main (pre-receive hook declined) error message.
Whoever initialized the repository (maybe you), set up a custom git hook to do some pre-checks before anything is pushed.

Merged code from repo not updating in production server after push

I have a post-receive hook in my server.
I also have a remote repo(origin) (branch:stage) where another developer pushes to.
I pull the commits and push them to production from my local computer.
I recently created a new branch(feature) from the latest head of the existing branch(stage), added some code and pushed the feature branch to remote repo. I merged the new features from feature branch to stage branch.
Then I pulled from the remote repo to local.
Now, I pushed the stage branch to production.
My post-receive file consists:
git --work-tree=/path/to/project --git-dir=/path/to/project.git checkout -
f stage
My head in the remote repo after merge is currently at ae228b9.
And, at the remote production hook's latest logs also points to ae228b9.
The problem is that the code from the merge are not seen in the production server.
Do I have to do something else to get the merged code to production?
After I pulled from origin and pushed to production, I tried changing the new files locally, committed them and push to the server. But, the changes are not reflected in the server.
Edit:
Also, I uninstalled apache php mysql and installed them again. Before the unistallation/installation, the home page was showing in server but the routes were not working(404 error) but the git hook was working. After the unistallation/installation, the git hook stopped working
Update:
I created a new hook with the same code as above. Now during the push I get:
remote: error: unable to unlink old '.gitignore' (Permission denied)
remote: error: unable to unlink old '.htaccess' (Permission denied)
remote: fatal: cannot create directory at '.idea': Permission denied
I tried the following code inside my project folder and project.git(hook) folder:
sudo chmod -R ug+w .;
unable to link
after which the push is a success but the changes are not reflecting.
I solved this by deleting the contents of the project folder and pushing again with some new changes.
I faced the same issue(Azure deployment)
There are two ways to ways to handle this -
Increase timeout setting (but deployment may stuck some times)
Push new changes (redeployment)
I prefer 2nd option.

Git:Heroku Repository or object not found:

Here is the error message from Heroku master push command
Git LFS: (0 of 5 files) 0 B / 167.50 MB
batch response: Repository or object not found: https://git.heroku.com/xxxx-brushlands-xx267.git/info/lfs/objects/batch
Check that it exists and that you have proper access to it
error: failed to push some refs to 'https://git.heroku.com/xxxx-brushlands-xx267.git'
Added a long text file to Git LFS (git for large files) and after that Heroku stopped working.
What might be the issue ?
A workaround:
git push heroku master --no-verify
This disables git-lfs pre-push hook. Metadata files are commited but binaries are not uploaded.
Then, as per upendra's answer, a buildpack can be used to download the files.
After alot of googling I found that the problem is with Heroku. If you are using Heroku, then Heroku doesn't support LFS and you have to look for alternatives.
I uploaded my long text file to dropbox and accessing it from there. Heroku should definitely look in to this issue.
I found a temporary solution to the problem of using Git LFS with Heroku. I am just putting it here just in case if people are still looking for it - https://github.com/git-lfs/git-lfs/issues/805
If that doesn't work, then try this out. This method worked for me - https://github.com/raxod502/heroku-buildpack-git-lfs

Can't push to git repository as normal user

There are a couple good posts on this subject, but I am not sure if they apply to my circumstances.
Error pushing to GitHub - insufficient permission for adding an object to repository database
Git Push Error: insufficient permission for adding an object to repository database
When performing a push as a normal user, I receive the following error:
remote: error: insufficient permission for adding an object to
repository database ./objects
Note that I can push if I am logged on the local machine as root. I see from the below that the origin is git#easybbb.com:root I don't know if it matters, but the remote repository I am trying to push to is hosted by me using GitLab.
The local git directory is 0775 and belongs to group "www", I've executed chmod -R g+rwxs /var/www/ to ensure that new files are of group "www", the normal user that is trying to push belongs to group "www", and I've executed git config core.sharedRepository group.
How do I fix this error?
git push origin master
Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 487 bytes | 0 bytes/s, done.
Total 6 (delta 5), reused 0 (delta 0)
remote: error: insufficient permission for adding an object to repository database ./objects
remote: fatal: failed to write object
error: unpack failed: unpack-objects abnormal exit
To git#easybbb.com:root/bidjunction.git
! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to 'git#easybbb.com:root/bidjunction.git'
git remote -v
origin git#easybbb.com:root/bidjunction.git (fetch)
origin git#easybbb.com:root/bidjunction.git (push)
It has nothing to do regarding the many similar questions. The key is "remote: error: ". The problem is the remote repository (GitLab which is similar to GitHub). Making all associated files owned by git solved the problem.

Git, having permission issues pushing

So I'm brand spanking new to Git and development in general. I'm a Linux and Mac user on a few different machines and have a couple cloud servers with AWS, I work on small little python projects on all of them.
I'll try to explain what I want first, hopefully I'm close to having the best solution that will work for my use case. I want to be able to write code on whatever device I own, Ubuntu desktop at home, work Macbook, cloud servers, Ubuntu desktop at work, and a personal Macbook. Obviously I'm working with different hostnames and usernames, I'm the only one that works on my code.
I went through the git guide and it's working, sort of. I tried to setup my repository on my cloud server which I will also be changing code on. I've been trying to commit and push from my Macbook but have been getting a string of permission errors all day, I've been having to go back to the repo and chown -R as my ssh wheel user since every object there is getting overwritten as root.
Here are some sample error messages I'm seeing when trying to push from my macbook:
A commit:
macbook:dev macbookuser$ git commit
# On branch master
# Your branch is ahead of 'origin/master' by 6 commits.
#
nothing to commit, working directory clean
And then the push:
macbook:dev macbookuser$ git push
user1#myserver-aka-repo.com's password:
Counting objects: 18, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (12/12), done.
Writing objects: 100% (14/14), 1.62 KiB, done.
Total 14 (delta 7), reused 0 (delta 0)
error: insufficient permission for adding an object to repository database ./objects
fatal: failed to write object
error: unpack failed: unpack-objects abnormal exit
To user1#myserver-aka-repo.com:/home/myserver-aka-repo/dev/.git
! [remote rejected] master -> master (n/a (unpacker error))
error: failed to push some refs to 'user1#myserver-aka-repo.com:/home/myserver-aka-repo/dev/.git'
If the chown and umask 0002 don't fix this on the server, make sure the repo you are pushing to has been shared with the right mode.
git config core.sharedRepository
See "Git Push Error: insufficient permission for adding an object to repository database" for more on this option.
I usually set core.sharedRepository to umask, and set my umask to 0002.

Resources