Git fetch和git pull的区别, 解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists).

2019-12-01 07:55:15

Git fetch和git pull的区别:

都可以从远程获取最新版本到本地

1.Git fetch:只是从远程获取最新版本到本地,不会merge(合并)

$:git fetch origin master   //从远程的origin的master主分支上获取最新版本到origin/master分支上$:git log -p master..origin/master //比较本地的master分支和origin/master分支的区别$:git merge origin/master          //合并123

2.Git pull:从远程获取最新版本并merge(合并)到本地

$:git pull origin master  //相当于进行了 git fetch 和 git merge两部操作1

实际工作中,可能git fetch更好一些, 因为在merge前,可以根据实际情况决定是否merge


再说导致报错:error: You have not concluded your merge (MERGE_HEAD exists).的原因可能是在以前pull下来的代码自动合并失败

解决办法一:保留本地的更改,中止合并->重新合并->重新拉取

$:git merge --abort$:git reset --merge$:git pull123

解决办法二:舍弃本地代码,远端版本覆盖本地版本(慎重)

$:git fetch --all$:git reset --hard origin/master$:git fetch123

参考以下链接:

http://stackoverflow.com/questions/11646107/you-have-not-concluded-your-merge-merge-head-exists

http://yijiebuyi.com/blog/5b55eb51ad49ce41e2de9c85dd4513ca.html

http://blog.csdn.net/hudashi/article/details/7664457


  • 2017-02-24 16:53:58

    PHP 中的Closure

    Closure,匿名函数,又称为Anonymous functions,是php5.3的时候引入的。匿名函数就是没有定义名字的函数。这点牢牢记住就能理解匿名函数的定义了。

  • 2017-03-02 09:45:27

    动态加载js和css

    开发过程中经常需要动态加载js和css,今天特意总结了一下常用的方法。