share repositories in windows with osx using “git push”
Problem
You have a git repos in Windows XP, and you want to share that with your MacOSX machine. The easiest way seems git clone in MacOSX. However, my win repos are in D drive and I did not find out how to write the repos path. I did
git clone tomoya@windows:d:\home\git.gitgit clone tomoya@windows:d:\\home\\git.gitgit clone tomoya@windows:d:/home/git.git
git clone tomoya@windows:"d:/home/git.git"
but all failed in vain.
Thus, I changed my mind to use git push from Windows.
Solution
SSH server on Windows
First, if you have not installed cygwin, or any SSH server for Windows, install freeSSHd. This programs runs on Windows as a SSH server.
create repository in MacOSX
[MacOSX] tomoya@macosx% cd ~/Workspace/git tomoya@macosx% git init
Add remote repository
[Windows] D:\home\git> git remote add origin tomoya@macosx:/Users/tomoya/Workspace/git
Try connectiing to remote
[Windows] D:\home\git> git remote show origin
Then I got a error as
Permission denied (publickey,keyboard-interactive). fatal: The remote end hung up unexpectedly
This is because my MacOSX requires key authentication. So, I specified pub.key files just by creating config file in %HOME%/.ssh/.
[Windows] D:\home\git> notepad "%HOME%\.ssh\config"
and, type
Host 192.168.1.21 User tomoya Port 22 Hostname 192.168.1.21 IdentityFile C:/id_rsa TCPKeepAlive yes IdentitiesOnly yes
Try connecting again.
[Windows] D:\home\git> git remote show origin zsh: command not found: git-upload-pack fatal: The remote end hung up unexpectedly
Great. I had these errors because my default login shell on MacOSX is zsh and my zsh does not know where git-upload-pack command is. Check whether git-upload-pack is installed correctly.
[MacOSX] tomoya@macosx% which git-upload-pack /opt/local/bin/git-upload-pack
OK. Now check if i have .zshenv file in your home directory.
[MacOSX] tomoya@macosx% cat ~/.zshenv cat: /Users/tomoya/.zshenv: No such file or directory
I do not. So I made a symbolic link to .zshenv.
[MacOSX] tomoya@macosx% ln -s ~/.zshrc ~/.zshenv
More detailed infomation about .zshrc and .zshenv can be found at here: http://zsh.dotsrc.org/Intro/intro_3.html.
Try connecting fot the third time.
[Windows] D:\home\git> git remote show origin * remote origin URL: tomoya@192.168.1.21:/Users/tomoya/Workspace/git HEAD branch: master Remote branch: master tracked Local ref configured for 'git push': master pushes to master (up to date)
Hoora! We made it. Ok, move on to next task.
Push to OSX
[Windows] D:\home\git> git push origin master
And on MacOSX,
[MacOSX] tomoya@macosx% ls ~/Workspace/git
If you see no files in this directory, this is because pushed files are deleted temporarily, so revert all the files as
[MacOSX] tomoya@macosx% git reset --hard HEAD
That’s all. Now you have the second repos in your Mac OSX.
Tags: git