Home > Eclipse, Git > Git on Windows

Git on Windows

I decided I need to come up to speed on Git and began the process of creating a Git repository on a windows server. It seemed like it should be pretty “easy” and I didn’t have any real problems finding a windows version of Git http://code.google.com/p/msysgit/ nor finding an ssh server http://mobassh.mobatek.net/en/ for Windows. Everything installed nicely, and when I tried to clone my first repository from the server to my laptop, I was prompted for my password on the server and successfully authenticated, but instead of things just working, I got a strange error about being unable to find “git-upload-pack“.

I figured out that the problem was that the PATH wasn’t being set correctly when the Git Gui client was attempting to connect. That seemed simple enough to remedy so I fired up putty on my laptop, connected into the server and did an “echo $PATH” to see what the path looked like. Sure enough, it was missing the “Git/bin” and ”Git/libexec/git-core” directories, the later being the home of the missing “git-upload-pack.” I updated my “~/.bashrc” file to add the directories to the path and optimistically expected things to just work.

Yeah, right.

I used putty to log back into the server to examine the path and discovered to my surprise that my additions were not there. I eventually figured out that I should have been updating “~/.bash_profile” and not “~./bashrc“. I also fixed a typo in my addition. So I ended up with the following in my “~/.bash_profile“:

export PATH=$PATH:/cygdrive/c/Progra~1/Git/libexec/git-core:/cygdrive/c/Progra~1/Git/bin

And, sure enough, when I logged back in with putty and examined the path, they were on it, and “which git-upload-pack” returned exactly what it should. At last, I was done, everything should just work, I fired up the Git-Gui on my laptop, give it the correct URL’s to clone the test repository on the server…and got exactly the same error that it was unable to find “git-upload-pack“.

An hour, or so, of bumbling around lead me to comparing the path returned from:

ssh myid@mygitserver echo \$PATH

with that obtained from putty…they were different. It turns out that the ssh session started by the Git Gui used “~/.bashrc” while that started by putty used “~/.bash_profile.”

The real problem was that I had gotten my first PATH fix wrong when I used “~/.bashrc” and had assumed that the problem was that I had the wrong file rather than simply having a typo in the path. That error was masked later when I discovered that I could change putty’s PATH from “~/.bash_profile” and I just assumed that that was the correct file to use. Once I put the correct path into “~/.bashrc” “everything” started working.

Now, it’s time for my plunge into the wonderful world of Git, I expect everything to just work.

Yeah, right.

Categories: Eclipse, Git Tags:
  1. May 25th, 2010 at 09:49 | #1

    We are in the process of releasing EGit 0.8.0 which help your situation quite a bit. It has JGit which is a 100% Java implementation of Git so you don’t need to deal with the mess of msysgit. Stay tuned to PlanetEclipse as I plan on blogging about it in the coming days…

  2. John
    May 25th, 2010 at 11:06 | #2

    Although it may seem useful, running a git server anywhere is not necessary to ‘get up to speed with git’. Regardless of whether there is a server in your network, most of learning of will be against a local repository. Further, the git commands for synchronizing to remote repository are indifferent to whether the repository resides on a remote server or on your local laptop.

    In short, seems to me you are doing extra work for little return unless your goal is specifically to learn how to setup a git repository on a windows server.

  3. daford
    May 25th, 2010 at 11:27 | #3

    Sounds great. The whole point of this process is to start using EGit and have Git as my repository of choice. Having struggled through getting msysgit working, I have a better understanding of how a few things work together, or don’t. The hardest part of the install was having to leave everything for a month while I was on business travel. I got back and couldn’t remember what I had done other than it didn’t work. :-)

  4. May 25th, 2010 at 17:16 | #4

    As others have said, you don’t need an ssh server to get started with git. You can use got init, and you are off. You only need a remote repository of you want a backup or share between devices which may not be connected at the same time.

    As for your bash woes: .bash_profile is called for “login” shells. Each new shell you create inside will source .bashrc instead. Depending on how you pass flags in to ssh determines if it is a login shell.

    It’s fairly normal to put in your .bash_profile:
    . .bashrc
    in your .bash_profile – that way, if you want to change paths, you put it in .bashrc and it works for either. The .bash_profile only then needs to contain stuff you only want to run once at login. Invariably though, it only contains a pointer to the .bashrc these days.

    Welcome to git!

  5. admin
    May 26th, 2010 at 10:17 | #5

    Yup, I want a remote repository for multiple machines and backup. From my googling of the problem, getting the PATH correct was a major issue for many people. Most configuration problems are trivial, but opaque if outside your mental model. Hopefully, someone else who is stuck will trip across my posting.

  1. No trackbacks yet.