commit your changes or stash them before you can merge

简介:

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

今天git pull 出现以下问题

复制代码
 
  

Please commit your changes or stash them before you merge.
Aborting
Updating c057de7..dbcc17b

 
复制代码

意思是 合并前请先提交你的代码,可是我的代码还没写完,我为什么要提交。

解决方案是这样

git stash 
git pull
git stash pop

git stash: 备份当前的工作区的内容,从最近的一次提交中读取相关内容,让工作区保证和上次提交的内容一致。同时,将当前的工作区内容保存到Git栈中。
git stash pop: 从Git栈中读取最近一次保存的内容,恢复工作区的相关内容。由于可能存在多个Stash的内容,所以用栈来管理,pop会从最近的一个stash中读取内容并恢复。
git stash list: 显示Git栈内的所有备份,可以利用这个列表来决定从那个地方恢复。
git stash clear: 清空Git栈。此时使用gitg等图形化工具会发现,原来stash的哪些节点都消失了。



相关文章
|
4月前
|
开发工具 git
合并commit
合并commit
35 0
|
开发工具 git
【错误记录】Git 使用报错 ( no changes added to commit (use “git add“ and/or “git commit -a“) )
【错误记录】Git 使用报错 ( no changes added to commit (use “git add“ and/or “git commit -a“) )
1669 0
【错误记录】Git 使用报错 ( no changes added to commit (use “git add“ and/or “git commit -a“) )
|
开发工具 git
多个commit合并成一个
当我们在本地仓库中提交了多次,在我们把本地提交push到公共仓库中之前,为了让提交记录更简洁明了,我们希望把如下分支A、B、C三个提交记录合并为一个完整的提交,然后再push到公共仓库。
136 0
|
开发工具 git
Git——合并(merge)
本文主要介绍 git merge的使用方式
278 0
Git——合并(merge)
|
开发工具 git
【Git】commit your changes or stash them before you can merge.解决办法
【Git】commit your changes or stash them before you can merge.解决办法
90 0
|
开发工具 git
Git 中 merge 和 rebase 的区别
$ git pull --rebase和$ git pull区别 是git fetch + git merge FETCH_HEAD的缩写,所以默认情况下,git pull就是先fetch,然后执行merge操作,如果加-rebase参数,就是使用git rebase代替git merge 。
24856 0
|
开发工具 git
Git合并分支出现 Please enter a commit message to explain why this merge is necessary.
Git合并分支出现 Please enter a commit message to explain why this merge is necessary.
2475 0
Git合并分支出现 Please enter a commit message to explain why this merge is necessary.
|
Java Go 开发工具
Git-Merge 的那点事儿
如果您在代码合并时发现 Git 合并结果不符合预期,您是否曾怀疑 Git 出现了 bug ?我希望您把这个选项放在最后。让我们一起来看看 Git-Merge 的那点事儿,一起来查找并解决代码合并的异常... ## 理解三路合并 Git 在分支合并时,采用三路合并的方法。不管合并的两个分支包含多少提交,Git 合并操作只关心代码的三个版本,即:合并双方的两个版本和一个基线版本。
744 0
|
开发工具 git
git rebase merge
git rebase merge
1107 0
|
开发工具 git
Git合并指定commit到当前分支
有时我们需要将指定的某一次commit合并到当前分支,比如线上的一次bugfix,只合并需要的commits。 首先,用git log或GitX工具查看一下你想选择哪些commits进行合并,例如: dd2e86 - 946992 -9143a9 - a6fd86 - 5a6057 [master] \ 76cada - 62ecb3 - b886a0 [feature] 比如,feature 分支上的commit 62ecb3 非常重要,它含有一个bug的修改。
2576 0