Git remote server Push fails - windows

After cloning a Git repo from my remote server, I have committed some changes on my local copy. I'd like to push these changes back to the remote server, but I'm getting an error message that yields no useful information:
fatal: read error: Invalid argument
(Ps. both the server and the local repo are running in Windows environments)
I have tried:
git push
git push origin
git push origin master
A push through the GUI version of GIT yields the same useful error message.
EDIT
After setting the Environment variable GIT_TRACE=1, I get slightly more output:
C:\repo>git push --verbose
setup: git_dir: .git
setup: worktree: C:/repo
setup: cwd: C:/repo
setup: prefix: (null)
trace: built-in: git 'push' '--verbose'
Pushing to git://MYSERVER.MYCOMPANY.net/repo
fatal: read error: Invalid argument
Any thoughts?

Looks like you're running in a plain cmd.exe terminal instead of msysgit's bash terminal. Much of git relies on shell scripts; thus, you need to run in a bash terminal instead of cmd.exe.

Are you sure the server is configured correctly, has your SSH key, etc? Did you home-brew the Git server or is this something like git-hub / assembla ?

Related

Git clone/push/pull of a remote share fails

a few of us use a bare repository on a network share ( u:\data\some_repo.git) and this works fine with the expected limitations
However, just recently I have been unable to perform any typical git activities associated with the bare respository: push pull clone.
All activities fail with:
fatal: 'u:\data\some_repo.git' does not appear to be a
git repository fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository
exists.
I do have access and I can browse this location fine. If I copy some_repo.git to my local machine and do a git clone /c/Temp/some_repo.git it works.
There is no latency issue, I have full access, I have tried prepending file:/// with no luck. a GIT_TRACE does not show anything
GIT_TRACE=1 git clone "/u/data/some_repo.git" 12:52:37.433340
exec-cmd.c:237 trace: resolved executable dir:
C:/STORAGE/Application/Git/mingw64/bin 12:52:37.435332 git.c:444
trace: built-in: git clone u:/data/some_repo.git Cloning into
'InternalTestInterface'... 12:52:38.129124 run-command.c:663
trace: run_command: unset GIT_DIR; 'git-upload-pack
'''u:/data/some_repo.git'''' 12:52:38.370091 exec-cmd.c:237
trace: resolved executable dir:
C:/STORAGE/Application/Git/mingw64/libexec/git-core 12:52:38.370091
git.c:444 trace: built-in: git upload-pack
u:/data/some_repo.git fatal: 'Hu:/data/some_repo.git' does not appear
to be a git repository fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository
exists.
Any idea how to resolve this
--update--
as requested, attempting to perform a git init:
/u/data/test.git
$ git init error: fstat on
//FQDN.com/site_###/Groups/data/test.git/.git/config failed: Invalid
argument fatal: could not set 'core.filemode' to 'false'
I have the exact same setup at work, with the same network drive (also named U:\!)
And I had the same issue at some point, apparently due to some background synchronisation/backup process which was keeping an handle on some of the files of the Git bare repository.
Try first to see if you can re-create a separate bare repo, for testing, and push to it:
git init U:\data\test.git
cd path\to\local\repo
git remote add origin2 U:\data\test.git
git push origin2 master

git plugin on windows command fails from Jenkins, succeeds in shell [duplicate]

This question already has answers here:
Unable to get Jenkins and Git to play nice
(2 answers)
Closed 7 years ago.
I'm setting up Jenkins on my windows build machine, with the Git Plugin. I'm using a directory on a network drive Z: as the git repository for now. I enter "z:\my\repo\path" for the Repository URL, and I get:
Failed to connect to repository : Command "git.exe -c core.askpass=true ls-remote -h z:\my\repo\path HEAD" returned status code 128:
stdout:
stderr: fatal: 'z:\my\repo\path' does not appear to be a git repository
fatal: Could not read from remote repository.
Yet if I open a fresh command prompt and type that command, it works without error (and also no output):
> git.exe -c core.askpass=true ls-remote -h z:\my\repo\path HEAD
>
What may possibly be the issue? I am not even sure where to begin. I've set the PATH and GIT_HOME system environment variables and restarted Jenkins, so clearly it is finding the executable.
I've tried the file:///-style path and had the same results.
Output of the manual command with GIT_CURL_VERBOSE=1 and GIT_TRACE=1 set:
15:43:24.905801 git.c:348 trace: built-in: git 'ls-remote' '-h' 'z:\\my\\repo\\path' 'HEAD'
15:43:24.905801 run-command.c:343 trace: run_command: 'git-upload-pack '\''z:\\my\\repo\\path'\'''
I believe the problem could be around correctly setting up the SSH keys.
First suggestion - UNC path for the repo
Can you try using the file://// format for the repo instead of windows path?
If it's a share try using git clone file:////<host>/<share>/<path> instead.
Please use this as reference.
Second suggestion - SSH Keys
From https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin- :
(though the error is different that what you have)
Some windows fun
If you did everything, you should now have a ~/.ssh folder
(c:\Users\Bob.ssh for instance) and this folder contains your keys.
At that point, you may even be able to manually (from the console),
clone your repository but Jenkins keeps failing with something like
this:
code 128: Cloning into C:\Program Files\Jenkins\jobs\PG3\workspace...
fatal:
The remote end hung up unexpectedly
If you run into this issue, you may need to copy the id_rsa* files
from your ~./.ssh to another folder. Find your git.exe and check if
there is an .ssh folder there. If so, copy ~./ssh/id_rsa* to this
folder and try again.

Github for Windows - can push/pull with git shell - Github GUI gives error

So I clone a private repo on my VPS using SSH with Git Shell. Now when I commit changes and try to push it to my VPS it says
"Sync failed: The repository doesn't seem to exist anymore. You may not have access, or it may have been deleted or renamed."
Whenever I go into Git Shell and do "git push origin master", I enter my password and it pushes it succesfully.
Why can't I do this through the Github client?

Git push not working but "git clone" and SSH does

I set up a Debian server that uses SSH for shell access and git repos. I created a bare repo on it and using ssh was able to clone it to my Windows 8 workstation, however when trying to push changes back to the Debian server I get the error depicted here:
Read from remote host 174.52.5.192: Connection reset by peer
fatal: sha1 file '<stdout>' write error: invalid argument
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'git#174.52.5.192:/home/git/repos/space-junk.git/'
I use this work station regularly for shell access to the same server via SSH so I know inability to access SSH isn't the problem.
Does anyone have any idea what's going wrong?
Actually, the first push should be:
git push -u origin master
That will link the local branch master to its remote tracking one origin/master
Then, after that first push, you will be able (for all the subsequent push) to do a simple:
git push
See more at "Why do I need to explicitly push a new branch?".
I got it working! It turns out the proper command was
git push origin master
The Windows version didn't have a descriptive enough error message but I got it working by switching over to Linux, which told me my command was wrong.

Git Bash Fatal:Could not read from remote repository

So I have a git repo set up on a linux machine and I typed
git remote add test git#*****.com:/opt/git/project.git
and then I did
git init
git add *
git commit -m 'Blah blah'
When I go to do
git push remotename
I get fatal:Could not read from remote repository.
I know it is a problem on my side, because my friend can on his arch linux machine. I have private ssh keys in a different folder then my git bash and then I have public keys in the git user home folder all set up. I don't know if I need to set up SSH keys somehow with git bash or something.
You need to add the upstream repo as a remote
git remote add remotename git#*****.com:/opt/git/project.git
And now do a push
git push remotename
PS : The step where you ran git add git#*****.com:/opt/git/project.git was meaningless, and should have thrown you an error ideally.

Resources