24 lines
1.4 KiB
HTML
24 lines
1.4 KiB
HTML
<p>push的时候提示fatal: refusing to merge unrelated histories</p>
|
||
<div> </div>
|
||
<div>假如我们的源是origin,分支是master,那么我们 需要这样写<code>git pull origin master ----allow-unrelated-histories</code></div>
|
||
<div><code> </code></div>
|
||
<div><code> </code></div>
|
||
<div><span style="color: #3f3f3f;">提示:</span></div>
|
||
<div>hint: Updates were rejected because the tip of your current branch is behind</div>
|
||
<p>hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')<br />
|
||
hint: before pushing again.<br />
|
||
hint: See the 'Note about fast-forwards' in 'git push --help' for
|
||
details.</p>
|
||
<div><code>
|
||
远程repository和我本地的repository冲突导致的,而我在创建版本库后,在github的版本库页面点击了创建README.md文件的按钮创建了说明文档,但是却没有pull到本地。这样就产生了版本冲突的问题。<br /><br />
|
||
有如下几种解决方法:<br /><br />
|
||
1.使用强制push的方法:<br /><br />
|
||
$ git push -u origin master -f<br /><br />
|
||
这样会使远程修改丢失,一般是不可取的,尤其是多人协作开发的时候。<br /><br />
|
||
2.push前先将远程repository修改pull下来<br /><br />
|
||
$ git pull origin master<br /><br />
|
||
$ git push -u origin master<br /><br />
|
||
3.若不想merge远程和本地修改,可以先创建新的分支:<br /><br />
|
||
$ git branch [name]<br /><br />
|
||
然后push<br /><br />
|
||
$ git push -u origin [name]</code></div> |