犯了一个低级错误:
server ip: 192.168.40.41
有一个git账户
所有的git仓库都在/home/git仓库下
比如/home/git/u-boot-2018.07-fmsh.git
我用了以下命令:
git clone 192.168.40.41:/home/git/u-boot-2018.07-fmsh.git
改过一些东西后,发现git push不上去
而且git clone时候输入的是我的账户密码,并不是git的密码
然后让同事帮忙看了一下:
git remote -v
origin 192.168.40.41:/home/git/u-boot-2018.07-fmsh.git (fetch)
origin 192.168.40.41:/home/git/u-boot-2018.07-fmsh.git (push)
git remote -h
可以显示命令的用法。
git remote set-url [--push] <name> <newurl> [<oldurl>]
git remote set-url origin [email protected]:/home/git/u-boot-2018.07-fmsh.git/
就是将<name>为origin的的新url设置为[email protected]:/home/git/u-boot-2018.07-fmsh.git/
所以[email protected]:/home/git/u-boot-2018.07-fmsh.git/的意思是:
git表示git用户,意思就是git用户艾特在192.168.40.41上,目录/home/git/u-boot-2018.07-fmsh.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 [email protected]:/home/zhangyi/tmp
需要输入zhangyi的密码,可以正常push pull。