在我们第一次关联Git库后,如果把Git配置信息删掉了,那么我们需要进行第二次关联:
一、git init
二、git remote add origin "Git库地址"
三、git add . 将本地工程文件夹所有内容添加至缓存区
四、git commit - m "信息关联"
五、git push
执行第五步可能出错:
fatal: Authentication failed for 'Git库地址'
解决:执行第六步:
六、git config --global user.name "用户名";git config --global user.email "邮箱"
执行第五步可能出错:
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
解决:执行第七步:
七、git push --set-upstream origin master
执行第六步可能出错:
error: failed to push some refs to 'Git库地址
解决:执行第八步
八、git pull origin master
执行第八步可能出错:
fatal: refusing to merge unrelated histories
解决:执行第九步
九、git pull origin master --allow-unrelated-histories
执行第九步后可能提示:
Automatic merge failed; fix conflicts and then commit the result.
然后重新执行:
git branch --set-upstream-to=origin/master master
文章参考:https://blog.youkuaiyun.com/Micheal_ZJ/article/details/79537401