最近想要将本地的项目上传到gitee的时候,git pull时遇到了一些问题:
问题1:
There is no tracking information for the current branch. Please specify which branch you want to merge with. See git-pull(1) for details git pull <remote> <branch> If you wish to set tracking information for this branch you can do so with: git branch --set-upstream-to=origin/<branch>
问题2:
fatal: refusing to merge unrelated histories
在本地项目根目录按照正常流程操作,先初始化本地仓库(git init),然后将本地所有项目文件添加到本地缓存(git add .)
然后将缓存区文件提交到本地仓库(git commit -m "本次提交说明")
将线下仓库和线上仓库进行关联(git remote add origin <线上仓库url>),
然后提交,第一次提交使用(git push -u origin master)master是主分支,
在这一步时提示:上传被拒绝。原因是远程仓库包含了其它文件(线上创建仓库时的初始化文件)没有被更新到本地,需要在(git pull)后再提交
按照上一步的提示,执行更新本地仓库操作(git pull),结果报出以下提示:当前分支没有跟踪信息,需要指定要合并的分支。原因是本地分支没有与线上分支进行关联,需要执行(git branch --set-upstream-to=origin/远程分支的名字 本地分支的名字)进行关联
执行关联动作,然后继续执行更新本地仓库动作,又出现提示:拒绝合并不相关的历史。原因是线下分支与线上分支被git认为是不同的仓库,所以不能直接合并
解决办法是在执行更新操作时允许不相关历史的分支进行合并,执行(git pull origin master ----allow-unrelated-histories),origin是线上仓库默认名字,master是线上分支名字
执行,可以更新成功
最后,执行提交(git push -u origin master),成功