Note that I have given up with Git server on widows, and moved to a Linux Mint distro that I set up, see Git on Mint.
I have a PC which I want to use as a backup for the Git projects’s on my laptop.
|NOTE, msysgit issue 457 means the windows git push will hang, and as of Feb 28th 2013 the recommendation is to revert to older versions of git, use Samba, use SSH or even move to JGit. That is until you find a very fine gentleman who has archived an old Git client which doesn't have the bug in.He posted to http://stackoverflow.com/questions/7104182/git-push-halts-on-writing-objects-100and his version of the client is at: https://skydrive.live.com/?cid=624606b9c3176d53&id=624606B9C3176D53%214848&authkey=!ANl5kSH_bExkzrk|
On both I will use c:\2013-dev\javaproject\ as the base dir. And in the example below I am working on a project called proj1.
NOTE: the server will use bare repositories which you cannot add to, only push to. The convention is to call these dir <proj>.git so you can tell this.
cd /c/2013-dev/javaprojects mkdir proj1.git cd proj1.git git init --bare git daemon --base-path=/c/2013-dev/javaprojects/ --export-all --enable=receive-pack --reuseaddr --verbose
Finally, I created a bat file for my own use to start the server
"C;\Program Files (x86)\Git\bin\sh.exe" --login -i -c 'git daemon --base-path=/c/2013-dev/javaprojects/ --export-all --enable=receive-pack --reuseaddr --verbose'
I also change the Git bash sh start dir to start up in c:\2013-dev\javaprojects by editing the shortcut properties.
cd c:\2013-dev\javaprojects mvn archetype:generate -DgroupId=com.jgibbons.proj1 -DartifactId=proj1 -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false cd proj1 mvn eclipse:eclipse git init git add * git commit -m "Initial commit" git remote add origin git://192.168.0.4/proj1.git git push -u origin master
Should IP of origin change:
git remote rm origin git remote add origin git://192.168.0.3/proj1.git git push
and should there be pushes into origin which you want, then
git pull origin master
If you wanted to then work in the pc which also hosts the git bare versions, you would start the git bash,
cd /c/2013-dev/localprojects/ mkdir proj1 git clone git://localhost/proj1.git proj1
On windows %HOMEPATH% is where .m2 repos and .gitconfig and so on are stored. eGit needs HOME to be set to this same location.
Useful stuff while playing on the client
# tells you if you have any already git remote -v # if you messed up and want to remove origin git remote rm origin # to see if you got it right git ls-remote origin
If it doesn’t work, then read the note at the top of this page - are you on that version of Git?
Do you then get:
$ git clone git://192.168.0.2/mapdesigner.git mapdesigner Cloning into mapdesigner... remote: Counting objects: 36, done. remote: Compressing objects: 100% (28/28), done. fatal: read error: Invalid argument fatal: early EOFs: 63% (23/36) fatal: index-pack failed
It appears that Git is basically rubbish on windows. I repeated the command about 5 times over about 5 minutes and eventually I got everything. So, just accept that Git is not as good as SVN, but its sexier so thats fine. (being a techie from 1873 I have used CVS, PVCS, Clearcase, SVN, Git and others over the years)