Git中从远程的分支获取最新的版本到本地有这样2个命令:

1. git fetch:相当于是从远程获取最新版本到本地,不会自动merge

git fetch origin master
git log -p master..origin/master
git merge origin/master

以上命令的含义:

   首先从远程的origin的master主分支下载最新的版本到origin/master分支上
   然后比较本地的master分支和origin/master分支的差别
   最后进行合并

2. git pull:相当于是从远程获取最新版本并merge到本地

git pull origin master


上述命令其实相当于git fetch 和 git merge
在实际使用中,git fetch更安全一些
因为在merge前,我们可以查看更新情况,然后再决定是否合并

当遇到"Commit your changes or stash them before you can merge"冲突时,这表明GIt保护您本地的代码修改,避免重要的修改丢失。有三种方法解决:

1. 提交代码修改:

git commit -m "My message"

2. Stash it:

Stash存储充当堆栈,您可以在其中推送更改,并以相反的顺序弹出它们

存储:

git stash

进行合并,然后拉出存储的修改:

git stash pop

3. 丢弃本地的修改:

git reset --hard

或者

git checkout -t -f remote/branch

或者为特定文件丢弃本地修改:

git checkout filename

Git更新本地仓库及冲突"Commit your changes or stash them before you can merge"解决的更多相关文章

  1. (转)Git冲突:commit your changes or stash them before you can merge. 解决办法

    用git pull来更新代码的时候,遇到了下面的问题: error: Your local changes to the following files would be overwritten by ...

  2. Git冲突:commit your changes or stash them before you can merge. 解决办法

    用git pull来更新代码的时候,遇到了下面的问题: 1 2 3 4 error: Your local changes to the following files would be overwr ...

  3. git pull和git merge区别&&Git冲突:commit your changes or stash them before you can merge. 解决办法

    http://blog.csdn.net/sidely/article/details/40143441 原文: http://www.tech126.com/git-fetch-pull/ Git中 ...

  4. Git更新本地仓库

    1.查看远程仓库git remote -v2.从远程获取最新版本到本地git fetch origin master:temp3.比较本地的仓库与远程仓库的区别git diff temp4.合并tem ...

  5. Git冲突:commit your changes or stash them before you can merge.

    用git pull来更新代码的时候,遇到了下面的问题: error: Your local changes to the following files would be overwritten by ...

  6. git fetch 的简单用法:更新远程代码到本地仓库及冲突处理

    Git中从远程的分支获取最新的版本到本地方式如下,如何更新下载到代码到本地,请参阅ice的博客基于Github参与eoe的开源项目指南方式一1. 查看远程仓库 1 2 3 4 5 6 $ git re ...

  7. 使用 Git 删除本地仓库和远端仓库文件

    使用 git bash 来删除 一.将文件(夹)添加到暂存区 这里假设本地和远端都有一个 test.txt 文件先在本地删除,通过 ·git status 查看通过git add test.txt 添 ...

  8. git原理-本地仓库认识

    项目人员使用git,几乎70%的工作都是在本地仓库完成的.由此可见本地仓库的重要性. 下面我们就通过一些基本的命令讲下git的本地仓库的结构,存储流程,数据类型,如何存储...... 仓库结构 大家都 ...

  9. git pull冲突:commit your changes or stash them before you can merge.

    今天用git pull来更新代码,遇到了下面的问题: error: Your local changes to the following files would be overwritten by ...

随机推荐

  1. c#序列化感悟(重点讲讲二进制序列化)

    序列化是一种通过将对象转化为字节流,从而达到储存对象,或者将对象传输到内存,数据库或文件的一个过程,主要用途是保存对象的状态(包括对象的数据),方便对对象的重建,反之读取就是反序列化. 三种序列化类型 ...

  2. 回顾 2021 中国 .NET 开发者峰会

    .NET Conf China 2021 是面向开发人员的社区峰会,基于 .NET Conf 2021,庆祝 .NET 6 的发布和回顾过去一年来 .NET 在中国的发展.峰会由来自北京.上海.苏州. ...

  3. X000101

    P3879 [TJOI2010]阅读理解 考虑用 Trie 解决 #include<stdio.h> #include<bitset> #include<string.h ...

  4. Thread的打断

    常用方法 public void interrupt() t.interrupt() 打断t线程(设置t线程某给标志位f=true,并不是打断线程的运行),不能打断正在竞争锁的线程. public b ...

  5. JDBC工具包commons-dbutils的基本介绍

    感谢原文作者:simonXi-tech 原文链接:https://blog.csdn.net/simonforfuture/article/details/90480147 更多请查阅在线API文档: ...

  6. iOS9新特性之常见关键字

    /* nullable:1.怎么使用(语法) 2.什么时候使用(作用) nullable作用:可能为空 nullable 语法1 @property (nonatomic, strong, nulla ...

  7. Java对数组的复制[转]

    原文地址http://x10232.iteye.com/blog/2230762 定义一个数组 int[] a={3,1,4,2,5}: int[] b=a: int[] a={3,1,4,2,5}: ...

  8. JAVA String介绍、常量池及String、StringBuilder和StringBuffer得区别. 以及8种基本类型的包装类和常量池得简单介绍

    一.概述 String是代表字符串的类,本身是一个最终类,使用final修饰,不能被继承. 二.定义方式   方式一:直接赋值法 String str1 = "hello"; 方式 ...

  9. Nodejs允许跨域访问

    状况:本地的前端项目(uni-app)以及后台管理(vue-mongo-node)和本地mongo数据库 前台项目端口是8082,后台数据接口是8081. 跨域解决,直接上代码: uni-app的ma ...

  10. GitHub page创建

      这是我的博客,才刚刚建成请多多指教 https://henryztong.github.io/ 以下地址都是关于创建GitHub 博客的: 地址 说明 https://pages.github.c ...