git使用时遇到的问题
今天在使用git链接我的仓库时遇见了几个问题
首先git的配置不再赘述
参照 https://zhuanlan.zhihu.com/p/31417255
我才用了两种方法链接外部,第一种是先执行
git clone git@github.com:********/document.git
这样即可成功
第二种方式是在已有的本地文件夹创建GIT,并关联到远程仓库中,
在这里我先执行以下指令
git init
git add ./*
git commit -m ""
git push
此时报错
fatal: No configured push destination.
之后使用
git remote add origin https://github.com/**/*.git
将本地的origin初始化
git push -u origin main
继续执行
报错
src refspec main does not match any
原因是本地新建的时候本地分支为master,注意这里的origin后面的意思是本地分支名
之后继续push
The current branch master has no upstream branch
原因是本地的没有绑定到远程的barch
git branch --set-upstream-to=origin/remote_name local_name
这个意思是绑定当前的barch与远程
git push -u origin master
这个是可以直接推送到同名的新分支或者创建