码迷,mamicode.com
首页 > 移动开发 > 详细

git推送报错: No path specified. See 'man git-pull' for valid url syntax或does not appear to be a git repository以及remote: error: insufficient permission for adding an object to repository databa

时间:2019-03-18 13:50:30      阅读:861      评论:0      收藏:0      [点我收藏+]

标签:服务端   perm   参数   链接   tin   权限   led   packer   搭建   

  本地(windows)代码想推送到linux自己搭建的git服务端,第一步是建立本地与服务端的关联,第二步是本地推送到服务端。

  第一步需要看你本地工程是否从git上clone来的,如果是clone来的那就不存在第一步了。但如果是本地已经有了工程之后才想同步到git上,需要先到linux的git上新增同名git仓库并初始化。这里以ms-util工程为例:

cd git
mkdir ms-util.git
cd ms-util.git
git --bare init

  接着修改用户属主和用户组属主,并让git仓库右执行权限:

cd ..
chgrp git ms-util.git -R
chown git ms-util.git
chmod 775 ms-util.git

  搞完上面这两步后用ll命令看到的应该是这样的:

drwxrwxr-x 7 git git 4096 Mar 17 21:54 ms-util.git

  搞完服务端接着搞本地客户端,打开git bash:

cd workspace/ms-util
git init
git remote add origin ssh://111.11.111.11/git/ms-util.git

  这样就建立了本地客户端与远程git服务端的连接了,本地的git仓库ms-uitl就可以push给服务端的同名git仓库了。但此时git远程url的路径不对,所以会报如下错误:

git push -u origin master
fatal: No path specified. See man git-pull for valid url syntax

  告诉你没有url链接,或者说url不是一个仓库:

git push -u origin master
fatal: /git/ms-util.git does not appear to be a git repository
fatal: Could not read from remote repository.

  那么正确的git链接长啥样呢?可以先参考下

git remote -v
origin  ssh://111.11.111.11:ms-util.git (fetch)
origin  ssh://111.11.111.11:ms-util.git (push)

  从上面没有加入用户,我们可以自己加,重新关联服务端git时,先把老的配置删掉

git remote rm origin
git remote add origin git@111.11.111.11:ms-util.git

  这样第一步就结束了,第二步的问题也就来了:

$ git push -u origin master
Counting objects: 10, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (10/10), 3.48 KiB | 891.00 KiB/s, done.
Total 10 (delta 0), reused 0 (delta 0)
remote: error: insufficient permission for adding an object to repository databa                                                                                                                se ./objects
remote: fatal: failed to write object
error: remote unpack failed: unpack-objects abnormal exit
To 111.11.111.11:ms-util.git
 ! [remote rejected] master -> master (unpacker error)
error: failed to push some refs to git@111.11.111.11:ms-util.git

  其实第二步的问题在设置第一步时已经埋下了。还记得这两条命令吗:

chown git ms-util.git
chmod 775 ms-util.git

  它们上了一个参数-R,导致ms-util.git里的用户和权限不对,当然无法在客户端push时写入服务端了。解决办法也很简单:进入linux下git目录

chown -R git ms-util.git
chmod -R 775 ms-util.git

  这时再回到windows下用git bash就可以push了:

 git push -u origin master
Counting objects: 10, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (10/10), 3.48 KiB | 891.00 KiB/s, done.
Total 10 (delta 0), reused 0 (delta 0)
To 116.62.136.56:ms-util.git
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

  以后再push无需再加上-u了。

 

git推送报错: No path specified. See 'man git-pull' for valid url syntax或does not appear to be a git repository以及remote: error: insufficient permission for adding an object to repository databa

标签:服务端   perm   参数   链接   tin   权限   led   packer   搭建   

原文地址:https://www.cnblogs.com/wuxun1997/p/10551573.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!