Git push command not working with msysgit setup - windows

I installed GIT onto my windows 2k8 server following these directions: http://code.google.com/p/tortoisegit/wiki/HOWTO_CentralServerWindowsXP
All commands work fine except the "push" command. I get this error:
git.exe push -v "origin" master:master
git: '/path/to/repo' is not a git command. See 'git --help'.
Pushing to user#ipaddress/path/to/repo
fatal: The remote end hung up unexpectedly
Does anyone know how to fix this?

It looks like the remote origin is not set up correctly.
I recommend re-creating that remote, either by renaming it or deleting it and making a new one:
git remote rename origin origin_backup
git remote add origin ssh://user:pass#address/path/to/repo.git
Then try again, preferably with a fetch before you push.
What protocol are you using? If git://, then make sure there is a Git daemon listening for connections. If ssh://, make sure you have ssh access and write permission on the appropriate directory tree.
Another possibility is that the server and client are running different versions of Git. It could cause problems if one is running a version that expects commands in the format git cmd and the other expects git-cmd.

First check, if your plain SSH access to 5.16.217.81 is working: is
ssh 5.16.217.81
able to open a connection to the host?
If that is successful, ensure that you specify the path to your repo in a way your SSH server understands. In the HowTo, the path is specified different from the path you typed:
5.16.217.81/d/private/test/ (your path) vs.
<server>:d:/DeeDriveRepos/Repo2
Obviously, the CopSSH server wants colons to separate the drive letter from the host, so that your URL should be 5.16.217.81:d:/private/test/.
If you used Cygwin, your URL would be 5.16.217.81/cygdrive/d/private/test/

My pushes work for msysgit version 1.6.5 but not for 1.7.x

Related

Windows, Git and the SSH url/path of a bare repository

I am trying to set up a git repository on our Windows server.
I installed OpenSSH for Windows and Git for Windows.
The OpenSSH server runs on port 2345 to filter out generic bots.
I created a bare and shared repository on C:\git\protocolrepo.git
I couldn't reach it with the URL:
ssh://User#domain#server.com:2345:C:/git/protocol.git
It seems to me to be a malformed URL but everywhere I look on the web I get this, but it just doesn't work.
As I found out in this thread: https://github.com/PowerShell/Win32-OpenSSH/issues/895, the shell might be the cause, so I set the powershell as the default shell of OpenSSH.
This didn't work either and I still needed to use this oddly formed URL.
So I installed Cygwin and set the Cygwin bash as the default shell, and used a more appropriately formed url:
ssh://User#domain#server.com:2345/cygdrive/c/git/protocol.git
I had a little bit more success with this, but it now states the following error message:
fatal: '/cygdrive/c/git/protocol.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.
The access rights should be fine as I make use of the same user alltogether, but I'm not 100% sure how this works on Windows.
I'm not sure either how Git/ssh handles this path on Windows.
On a Linux based server this worked just fine with /git/protocol.git path.
Pushing a new branch to a bare repository is something I haven't done in a while either so that also might be done wrong here, but I can't recall it to be an issue.
What would you recommend to debug this issue?
I would start by checking if an interactive SSH session works, before considering using a Git repo SSH URL.
ssh -p 2345 User#domain#server.com
If it does, try and access /C/git/protocol.git in that interactive shell.
If that works, then try for your git commands the URL
ssh://User#domain#server.com:2345/C/git/protocol.git
# or
ssh://User#domain#server.com:2345/c/git/protocol.git

Git how to access repository Windows local machine?

I installed Git for Windows in order to clone and pull a project hosted on a remote Linux server.
In my repository (D:/repositories/my-project) I launch the following commands
git clone server#192.168.56.101:/var/www/web/my-project/.git
git pull origin master
So far so good. I pull the project files whenever modifications are applied on the server.
But now I'd like to pull or push from the remote server to my local repository.
I tried many things but I can't figure out how to access the repository located on my local machine.
Things like:
git pull duddy#my-pc:/d/repositories/my-project/.git master
just doesn't work, Git says:
ssh: Could not resolve hostname my-pc: Name or service not known
fatal: Could not read from remote repository.
Can someone helps me ?
First things first, I would recommend you try simply running git pull.
If this doesn't work, try running git remote -v and check to make sure that the URL for your server is listed as an origin (server#192.168.56.101:/var/www/web/my-project/.git).
Your issue is that you are inputting the URL for your local repository in your attempt to git pull.
I suggest reading the git-pull documentation to learn more about how pull works.
Basically, you need to have some service at your workstation which serves the requests. There are following options (I did not try most of them myself, just making it up from what I know):
use the windows file access. This is the easiest to setup at the windows workstation - just share the repository folder. The Linux side should somehow be able to mount windows shares (like described, for example, here: https://wiki.ubuntu.com/MountWindowsSharesPermanently). If you manage to mount your \\my-pc\repo to some /mount/my-pc-repo, then you can access it as file:///mount/my-pc-repo.
run git daemon at windows. Set up instructions are available at SO (for example, https://stackoverflow.com/a/2275844/2303202) and it pretty straightforward, but it does not have any authentication and in most cases it is reasonable to use it only for reading, so you will not be able to push to the workstation, only fetch.
set up ssh daemon and access through ssh authentication with read-write access. Git for windows installation contains the needed software (the sshd.exe binary, it is there at least for Git for Windows 2.6.0), probably there is a way to utilize it but I could not find it quickly.
set up HTTP(S) service at your workstation. I don't know if it is possible to do only with Git for Windows (it might be, with some perl module which happen to be included with it), or you should use some other software.

Need help setting up a git server on windows

i'm trying to set up a git server on Windows, but i'm having some issues getting it all to work.
I have locally created a normal repository, and remotely i created a bare repository. On the local repository i added a single text file and committed it, but when I try to push it into the remote repository I always get the following message:
fatal: protocol error: bad line length character: fata
I searched SO and other sources, and most of them suggest it's an issue regarding command echos. I'm using freeSSHd as a SSH solution (remote repository is hosted on a windows server), and I tried to use both the git bash and the windows CMD as a command shell.
I start CMD with /Q to disable echoing and /K to change directory to a directory where repositories are located, so I don't think that would be a problem.
Using the remote desktop, i can clone the repository to a folder next to it, and using the git bash locally i can access the SSH shell and also clone the repository in the same way. But using git clone ssh://<address>:/myRepo.git I always get the above message (The SSH's working folder is the same where the repository is located). Does anyone have any idea what's going on? How can I see what command is triggering the error, and how can I see the full error message?
I also met the same error using freeSSHd as a ssh solution for git server on Windows. I couldn't find a solution for a whole day and gave up. :(
Later I found another powerful ssh server from Bitvise called WinSSHD worked well. It has free version for personal use. I suggest you to switch to it. Though I'd also like to know if there's a fix to the error we both met.
To setup ssh server with WinSSHD is quite simple, and you can add virtual accounts with private/public key access.
The key part is to setup the ssh access for git server. Please follow the steps of the blog here.
It should work well for Windows git client. For Mac, you may meet an error as follows.
grp.sh: No such file or directory
fatal: Could not read from remote repository.
To fix it, you need to create the two files gup.sh and grp.sh in your git bin directory (GIT_PATH/bin or GIT_PATH/libexec/git-core configured in system environment variable PATH) in your git server.
The content of gup.sh:
git-upload-pack.exe $*
The content of grp.sh:
git-receive-pack.exe $*

Git remote end hung up unexpectedly

I am trying to set up a git repo on my test server when I try to push from my windows computer
git push ssh://git#server.com:/path/.git
I get the error
fatal: The remote end hung up unexpectedly
But when I ssh'd into my server and tried to do the the exact same command it worked just fine. Is this a problem with my git setup or with my windows setup
The problem might be caused by a number of issues:
Git is installed in some weird place on the server, and the environment that "git" user gets when being logged in interactively (you do this by hand via PuTTY or whatever) differs from the environment it gets when being logged in non-interactively (the git client does this for you). This is because Unix shells read different startup files in these cases, and when git uses SSH to spawn remote git instance it still spawns the default (for the user) shell on the server.
You have a local problem (say, you configured Git to use plink.exe to access the server, and it asks you to accept the host's key by entering "y" or "n" (which you can't do).
In any case, try these steps:
Run plink.exe git#server.com "git --version" and see it's able to run Git on the server at all. If you don't use plink.exe use whatever binary is shipped with OpenSSH included with Git for Windows; probably it's ssh.exe.
Export GIT_TRACE=1 before running git push and see if it prints out anything hinting at what went wrong, like this:
C:\foo>GIT_TRACE=1
C:\foo>git push ssh://git#server.com:/path/.git
I suspect the problem is that the user 'git' does not have write access to the remote repository, and that you may be connecting manually with your own username (cemurray, or some such).

How to git clone a repo in windows from other pc within the LAN?

I have this git repo "c:/xampp/htdocs/**" in my main PC and its IP address is 192.168.0.6. Now I want to git clone this repo from ubuntu-server which running on a Vmware Player in my main PC.
I did
git clone \\192.168.0.6\c:\xampp\htdocs\****
and
git clone //192.168.0.6/c:/xampp/htdocs/****
from ubuntu-server and neither worked.
fatal: could not create work tree dir '****'.: Permission denied
What did I wrong?
what should I do?
You should use the command git daemon to host your repo, like this:
In your computer that will act as a server:
git daemon --base-path=<path_to_folder_containing_project_folder> --export-all
(please note that path_to_folder_containing_project is the folder containing your projects folders, it will provide all projects under that folder)
In your client:
git clone git://<local ip>/<project name>
The cloned repo will have its origin pointing to the server in your LAN, so you may want to use git remote set-url origin to point it to the original origin.
You may want to run git daemon with the --verbose option to get more details in case you run into problems.
Make sure that your c:/xampp/htdocs folder (or sub folders of it) is shared in windows, so you can navigate on the network by this address:
\\192.168.0.6\htdocs
Then you clone by using file:////. Note that there are four slashes:
git clone file:////192.168.0.6/htdocs/somerepo.git
To access the repo, you must either share it on 192.168.0.6 or must be the same domain user as the one that owns the file on 192.168.0.6.
If you share the directory on 192.168.0.6 (e.g. with share name myrepo), you access it with //192.168.0.6/myrepo.
If you are logged in on your box with a user accout that is known on 192.168.0.6, you could try accessing the repo through the administrative shares:
//192.168.0.6/c$/xampp/htdocs/...
Always use forward slashes.
Another alternative would be using SSH to access the remote machine.
Using explorer (smb) to mount the remote repository as a network share is the easiest way. I'm not entirely sure, but I think you paths might be wrong. Try file:///192.168.0.6\c:\xampp... instead.
There are two things that might have gone wrong for you:
You don't have read permission on the remote repository
You don't have write permission in the location you want to create your repository ( the current working directory or the directory you specify as second argument to git clone)
And also check if your samba server works for normal file access.
To make git repo on Windows local network you'd need to do the following:
Create new repo
git init --bare projectName.git
Share this folder (projectName.git) with the users you need
Find your PC ip with ipconfig command (e.g. 192.168.2.101)
Run this command from some user's machine
git clone //192.168.2.101/projectName.git
Note: open \\192.168.2.101 in finder to see the correct path to the projectName.git (e.g. //192.168.2.101/some/path/projectName.git)
I recently ran into this error while trying to clone a repository in a remote pc to a local pc within the same LAN network.
The solution was to first make sure the drive location in the remote pc had the correct access rights for the local PC(Read/Write-which can be set using windows sharing options)
Copy the path of the remote repository. In your local pc paste the path in a windows explorer window. Then copy its directory address and paste it into any browser.
Now you should get a link with the hostname and the correct cloning URL format.
Use this link to clone the repository in the local pc.
Hope this helps.
Cheers.
"I have a few different computers that I use at home and I wanted to set up GIT that I can access my code from any of them. It took me a bit because I was too used to working with a client-server model where I designate one machine as the "server" that holds the repository and everything else was a client. Instead, GIT seems to operate more like a merge tool and every local copy is its own "master." Once I understood that, it turns out that setting up GIT is very simple and just needs GIT itself and SSH".
To read more you can check this link:
http://blog.lazyhacker.com/2010/04/setting-up-git-for-home-network.html

Resources