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


  • 2020-02-19 23:04:52

    理解Laravel中的pipeline

    pipeline在laravel的启动过程中出现次数很多,要了解laravel的启动过程和生命周期,理解pipeline就是其中的一个关键点。网上对pipeline的讲解很少,所以我自己写一写吧。

  • 2020-02-19 23:08:56

    Laravel 用户认证 Auth(精华)

    很多应用是需要登陆后才能操作,Laravel 提供了一个 auth 工具来实现用户的认证功能。并且有一个 config/auth.php 来配置 auth 工具。大概看一下 auth 工具的常用方法

  • 2020-02-19 23:12:44

    Laravel 从 $request 到 $response 的过程解析二(必读)

    laravel 的请求会组装成 $request 对象,然后会依次经过中间件(前置部分),最终到达 url 指向的控制器方法,然后把返回数据组装为 $response 对象返回,再依次经过中间件 (后置部分),最终返回。

  • 2020-02-19 23:15:24

    PHP 闭包(Closure)

    闭包(Closure)又叫做匿名函数,也就是没有定义名字的函数。比如下面的例子: