commit your changes or stash them before you can merge

栏目: 编程工具 · 发布时间: 7年前

内容简介:今天用git pull来更新代码,遇到了下面的问题:通常遇到这个问题,你可以直接commit你的修改;但我这次不想这样。

今天用git pull来更新代码,遇到了下面的问题:

error: Your local changes to the following files would be overwritten by merge:
    .gitignore
Please, commit your changes or stash them before you can merge.
Aborting

1. stash

通常遇到这个问题,你可以直接commit你的修改;

但我这次不想这样。

看看git stash是如何做的。

git stash
git pull
git stash pop

接下来diff一下此文件看看自动合并的情况,并作出相应修改。

git stash : 备份当前的工作区的内容,从最近的一次提交中读取相关内容,让工作区保证和上次提交的内容一致。同时,将当前的工作区内容保存到Git栈中。

git stash pop : 从Git栈中读取最近一次保存的内容,恢复工作区的相关内容。由于可能存在多个Stash的内容,所以用栈来管理,pop会从最近的一个stash中读取内容并恢复。

git stash list : 显示Git栈内的所有备份,可以利用这个列表来决定从那个地方恢复。

git stash clear : 清空Git栈。此时使用gitg等图形化 工具 会发现,原来stash的哪些节点都消失了。

2. 放弃本地修改,直接覆盖之

git reset --hard
git pull

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Software Engineering for Internet Applications

Software Engineering for Internet Applications

Eve Andersson、Philip Greenspun、Andrew Grumet / The MIT Press / 2006-03-06 / USD 35.00

After completing this self-contained course on server-based Internet applications software, students who start with only the knowledge of how to write and debug a computer program will have learned ho......一起来看看 《Software Engineering for Internet Applications》 这本书的介绍吧!

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具