git clone的低级错误


犯了一个低级错误:

server ip: 192.168.40.41

有一个git账户

所有的git仓库都在/home/git仓库下

比如/home/git/u-boot-2018.07-fmxx.git

 

我用了以下命令:

git clone 192.168.40.41:/home/git/u-boot-2018.07-fmxx.git

改过一些东西后,发现git push不上去

而且git clone时候输入的是我的账户密码,并不是git的密码

 

然后让同事帮忙看了一下:

git remote -v

origin  192.168.40.41:/home/git/u-boot-2018.07-fmxx.git (fetch)
origin  192.168.40.41:/home/git/u-boot-2018.07-fmxx.git (push)


git remote -h

可以显示命令的用法。

git remote set-url [--push] <name> <newurl> [<oldurl>]

 

git remote set-url origin git@192.168.40.41:/home/git/u-boot-2018.07-fmxx.git/

就是将<name>为origin的的新url设置为git@192.168.40.41:/home/git/u-boot-2018.07-fmxx.git/

 

所以git@192.168.40.41:/home/git/u-boot-2018.07-fmxx.git/的意思是:

git表示git用户,意思就是git用户艾特在192.168.40.41上,目录/home/git/u-boot-2018.07-fmxx.git/下的仓库。

这时候push pull 都是git的密码了,能成功。

 

我又新建了一个仓库,/home/zhangyi/tmp

git init --bare #建立了一个裸仓库

git clone 192.168.40.41:/home/zhangyi/tmp

#这样可以push 因为是同一个用户吧,后来用其他用户git clone 不加zhangyi@,出现了不能push的错误

error: remote unpack failed: unable to create temporary object directory
To 192.168.40.41:/home/zhangyi/tmp
 ! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to '192.168.40.41:/home/zhangyi/tmp'

git remote -v

origin  192.168.40.41:/home/zhangyi/tmp (fetch)
origin  192.168.40.41:/home/zhangyi/tmp (push)

 

在其他用户下

git clone zhangyi@192.168.40.41:/home/zhangyi/tmp

需要输入zhangyi的密码,可以正常push pull。


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM