Git clone/push/pull of a remote share fails - windows

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

Related

Git Submodule - Unable to Access Repository using Linux Subsystem for Windows

I'm trying to add a Git submodule to a different repository. I created the repository I want it in, but the submodule was created by my advisor.
For convenience, let's say the submodule I'm trying to add is repository A and the one I'm trying to add it to is repository B.
A couple of notes:
I'm using the Linux Subsystem for Windows (i.e., the Ubuntu terminal app).
I have an active internet connection and can access both repositories via the standard git commands (git pull, push, commit, etc.)
I can get all my code working fine using symbolic links to A.
Here are the steps I'm taking to add A to B, and the corresponding terminal outputs.
In: git submodule add git#gitlab.com:Respository_B
The above line worked fine, and I can see the correct info in the .gitmodules file, this is the output:
[submodule "Repository_B"]
path = repository_B
url = git#gitlab.com:Repsitory_B
Now, I tried the following two things:
In: git submodule init
Out: fatal: No url found for submodule path 'submodule_A' in .gitmodules
and,
In: git submodule update --remote
Out: setsockopt IPV6_TCLASS 8: Operation not permitted:
I'm stumped. I tried searching for a solution online, but came up empty-handed. Any ideas on how to fix this?
Also, if I need to clarify anything, please let me know.
Thank you!
EDIT
I just read that there are some chmod issues with the Windows subsystem, so I tried this line and got a different error message.
In: sudo git submodule update --remote
Out: git#gitlab.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Unable to fetch in submodule path 'Repository_A'
This is weird, because I am able to access the repository using a symbolic link I made to a local clone.
I'm trying to add is repository A and the one I'm trying to add it to is repository B.
Then the command would be:
cd /path/to/B
git submodule add git#gitlab.com:Respository_A
git commit -m "Add A to B"
git push
Regarding the error message, this issue suggests:
A workaround that we are using is to put the following line in ~/.ssh/config:
AddressFamily inet
Note: Using AddressFamily inet works great if you're connecting to an IPv4 host. If the host is IPv6 only, it won't connect at all.

Git: Internal error: refs/remotes/origin/master is not a valid packed reference

I am attempting to clone a git repository on a Windows network drive, but the process fails. It first throws a internal error: refs/remotes/origin/master is not a valid packed reference, and then repeatedly relates that it failed to unlink an index file.
x:\code\source> git clone x:\code\repos\project.git
Cloning into 'project'...
done.
error: internal error: refs/remotes/origin/master is not a valid packed reference!
fatal: update_ref failed for ref 'HEAD': cannot update the ref 'HEAD':
Trying to write ref refs/heads/master with nonexistent object d34950c3faee46d8a7f3b8e7950b04fcc5da9d1c
Unlink of file 'project/.git/objects/pack/pack-....idx' failed. Should I try again? (y/n)
I am able to clone without issue to a local drive from a bare repo on the network drive, but am unable to clone to a network drive.
When cloning to a mapped network drive using a standard Windows command prompt, you need to preface the from path with file://.
E.g.,
git clone file://x:\code\repos\project.git
or, if there are spaces,
git clone "file://x:\my code\repos\project.git"
You cannot, however, do the same when specifying the target.
** DOESN'T WORK **
git clone file://x:\code\repos\project.git file://y:\code\source\project
Instead,
cd y:\code\source
git clone file://x:\code\repos\project.git project
For future readers who are trying to use GitExtensions and getting this error: David C's answer works for our purposes as well, and you can type in file:// before the 'Repo to clone' location name.
This error arises when the Repo to clone and destination directory are both on a local network drive.

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.

Unable to Change my Remote Repo

I am a bit new to git, and as a result I have gotten myself into a git mess. I have an Xcode 4.5 project. In the command line I have been managing its local git repo as well as a remote repo on github that the local one is linked to. All was well until I decided to delete the remote repo on the GitHub website (called PictureFly) and create a new remote repo on the GitHub website (called PhotoFly). I would like my local repo to be unlinked to the old remote repo (PictureFly) and linked to the new remote repo (PhotoFly). Seems simple, but no matter what command I enter, I get one fatal warning or another. Here is a typical example of what I have been doing:
My attempts to remove the old remote origin:
//first attempt
git push origin :https://github.com/jac300/PictureFly.git
//first error
fatal: remote part of refspec is not a valid name in
:https://github.com/jac300/PictureFly.git
//second attempt
git push origin :PictureFly.git
//second set of errors
fatal: '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.
//third attempt
git push origin --delete PictureFly
//third set of errors
fatal: '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.
//fourth attempt
git push origin --delete https://github.com/jac300/PictureFly.git
//fourth set of errors
fatal: '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.
Then I thought maybe I can just add the new remote repo:
git remote add origin https://github.com/jac300/PhotoFly.git
fatal: remote origin already exists. //how does it already exist?
So since it "already exists" I tried to push to that repo:
git push -u origin master
fatal: 'git' does not appear to be a git repository
fatal: Could not read from remote repository.
I have no idea what is happening or how to fix it. Any help is appreciated.
You can easily remove the repo on GitHub and create a new empty one from the website. So now you're stuck with your remotes pointing to the wrong url. To fix:
git remote set-url origin https://new.url.here

Git remote server Push fails

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 ?

Resources