如何使git合并处理我的工作树的未提交更改? [英] How to make git merge handle uncommitted changes to my working tree?

查看:1778
本文介绍了如何使git合并处理我的工作树的未提交更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一位同事和我现在都在主分支上工作。我在我的工作树中有一些我不想提交的代码(调试语句等)。现在,如果他将更改提交给某些相同的文件,我无法合并它们:

  $ git merge origin / master 
更新1b8c5c6..eb44c23
错误:条目'blah.java'不是最新的。无法合并。

从颠覆背景来看,我习惯于让我的工作树在我修改时自动合并从存储库中,如果有冲突,我手动解决它们。



我发现在git中这样做的最快捷方式是:

  $ git stash 
$ git merge origin / master
$ git stash pop

实质上,删除未提交的更改,进行合并,然后重新应用更改。我怎么能告诉合并自动合并我的工作树与我试图拉的变化?

解决方案

至于我可以告诉你,你可以做的最好的事情就是你已经有了 git stash 。我也觉得合并只想处理干净的树木很奇怪。


A co-worker and I are both working on the master branch at the moment. I have some code in my working tree that I don't want to commit (debugging statements and the like). Now if he commits changes to some of those same files, I can't merge them:

$ git merge origin/master
Updating 1b8c5c6..eb44c23
error: Entry 'blah.java' not uptodate. Cannot merge.

Coming from a subversion background, I'm used to having my working tree automatically merged when I pull changes from the repository and if there are conflicts, I resolve them manually.

The quickest way I have found to do this in git is:

$ git stash
$ git merge origin/master
$ git stash pop

Essentially, removing my uncommitted changes, doing the merge and then re-applying the changes. How can I tell merge to automatically merge my working tree with the changes I'm trying to pull in?

解决方案

As far as I can tell, the best you can do is what you already have with git stash. I too find it strange that merge wants to deal only with clean trees.

这篇关于如何使git合并处理我的工作树的未提交更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆