开发者

git clone over ssh creates a local repo instead of a remote repo

开发者 https://www.devze.com 2023-04-02 22:16 出处:网络
I have the following me@mba ~/Documents/myproj$ll total 8 drwxr-xr-x13 punkishstaff442 Sep5 15:13 .git/

I have the following

me@mba ~/Documents/myproj$ll
total 8
drwxr-xr-x  13 punkish  staff  442 Sep  5 15:13 .git/
-rw-r--r--   1 punkish  staff  193 Sep  5 13:28 foo.pl
me@mba ~/Documents/myproj$git clone --bar开发者_如何学编程e . ssh://me@macpro.edu:2200/~/Repos/myproj/
Cloning into bare repository ssh://me@macpro.edu:2200/~/Repos/myproj... done.
me@mba ~/Documents/myproj$ll
total 8
drwxr-xr-x  13 punkish  staff  442 Sep  5 15:13 .git/
-rw-r--r--   1 punkish  staff  193 Sep  5 13:28 foo.pl
drwxr-xr-x   3 punkish  staff  102 Sep  5 15:20 ssh:/
me@mba ~/Documents/myproj$

huh! What happened there? Instead of a bare repo getting created on the remote computer over ssh port 2200, it got created right in the current directory on my laptop. I am doing something silly but it is not obvious to me.


ssh -p 2200 me@macpro.edu 'mkdir -p ~/Repos/myproj && cd ~/Repos/myproj && git init --bare'
git remote add origin ssh://me@macpro.edu:2200/~/Repos/myproj/
git push origin master

Should work. At least this is the idea: Login into the remote and create the bare repository. Then on your local machine add the newly created bare repository as remote and push everything you like.

However, you can also create a local clone of your repository and then copy the whole folder using scp or rsync or such to your remote.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号