本地写了一个项目,此时还没有和远程库关联,项目开始初始化差不多了,然后在gitee上建一个库做关联,存放项目。
首先,
本地库和远程库做关联:git remote add git@gitee.com:******.git
做好关联之后以为就可以提交了,但是你错了,因为远程项目跟本地项目不一致,外加你们的分支还没有关联
觉得使用git pull就可以更新,结果报错:
You asked to pull from the remote 'origin', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.
解决方法是,打开.git下得config文件夹添加如下:
[branch "master"]
remote = origin
merge = refs/heads/master
origin是你自己定义得远程库得名字
这个时候应该可以pull了吧,结果还是不对,报错:
fatal: refusing to merge unrelated histories
因为他们是两个不同的项目,要把两个不同的项目合并,git需要添加一句代码:–allow-unrelated-histories
执行:
git pull gitee master --allow-unrelated-histories
这个时候我们就可以愉快的push了。
参考地址:http://stackoverflow.com/questions/4847101/git-which-is-the-default-configured-remote-for-branch
参考博文:https://blog.youkuaiyun.com/lindexi_gd/article/details/52554159
参考博文:https://blog.youkuaiyun.com/u012028371/article/details/52384882
这个博文这儿有一张图,博主对git理解比较深:https://blog.youkuaiyun.com/kindle_code/article/details/52196511