git推送报错: No path specified. See 'man git-pull' for valid url syntax或does not appear to be a
Posted 不想下火车的人
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了git推送报错: No path specified. See 'man git-pull' for valid url syntax或does not appear to be a 相关的知识,希望对你有一定的参考价值。
本地(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 [email protected]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 ‘[email protected]: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 的主要内容,如果未能解决你的问题,请参考以下文章
ERROR: No query specified(Mysql数据库报错)
struts 报错 No action config found for the specified url
tp5.1路由报错No input file specified.
git服务端问题解决 fatal: No remote repository specified. Please, specify either a URL or a remote name fr