git clone之后再去git push遇到的问题(The current branch master has no upstream branch)和(you can't push to...)

xiaoxiao2021-03-01  64

   目前正在做一个Laravel的项目,考虑到以后的团队合作,所以就用git clone git://github.com/dengao123/sample.git类似的命令获取了远程的仓库代码,但是当我用git push提交代码时确遇到了2问题。

1. 第一次提交时

you can't push to  git://github.com/dengao123/sample.git​​​​​​​use https://github.com/dengao123/sample.git​​​​​​​

原因是因为,我是用clone命令下载的代码,没有写的权限,只有读的权限,解决方法:

git remote rm origingit remote add origin git@github.com:dengao123/sample.git​​​​​​​

​​​​​​​​​​​​​​2.  解决完上个问题后再一次提交时

 

    fatal: The current branch master has no upstream branch.    To push the current branch and set the remote as upstream, use     git push --set-upstream origin master

原因是因为,没有将我clone下来的代码分支没有与远程的代码分支进行关联,解决方法

git remote -v 查看远程代码仓库,显示    

origin git@github.com:dengao123/sample.git (fetch) origin git@github.com:dengao123/sample.git (push)

然后执行命令

git push --set-upstream git@github.com:dengao123/sample.git master

 

​​​​​​​再次运行git push 成功,(所有命令都是在master分支下操作)

​​​​​​​

转载请注明原文地址: https://www.6miu.com/read-3350292.html

最新回复(0)