为什么通过提交引入的更改不会显示在我的工作树中? [英] Why do the changes introduced by a commit not show up in my working tree?

查看:93
本文介绍了为什么通过提交引入的更改不会显示在我的工作树中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,git说一个提交被合并,但
从提交改变不在我的工作树中。为了让事情变得更加奇怪,
git log --name-status 362dde7 告诉我提交修改了一个文件,但
git log - path / to / modified / file.java 不显示提交。例如:

确保提交的问题在开发分支和功能分支上都存在。



<$ p $ $ git branch --contains 362dde74f142831c99820b999558a2e8f49f66e8
* dev
feature

列出由提交修改的文件。

  $ git show --name-status 362dde74f142831c99820b999558a2e8f49f66e8 
#commit summary ...#
M path / to / modified / file.java

  $ git log现在,当我做相反的操作时(列出修改文件的提交) path / to / modified / file.java 
#提交362dde7未在此列出

如果我切换到功能分支,并按照相同的步骤,一切都按预期工作。

  $ git结帐功能
$ git show --name-status 362dde74f142831c99820b999558a2e8f49f66e8
#commit summary ...#
M path / to /modified/file.java
$ git log path / to / modified / file.java
362dde7提交摘要

基本上,在 dev 特性上都存在相同的提交,但工作树只有在功能已签出时才会显示更改。有谁知道为什么会发生这种情况?


在/tmp/g/so19234836/.git/
$ cd中初始化的空Git存储库so19234836 /
$ echocontent created>文件
$ git添加文件
$ git commit -m c1
[master(root-commit)a965818] c1
1个文件已更改,1个插入(+)
创建模式100644文件
$ git checkout -b功能
切换到新分支'功能'
$ echo功能更改>文件
$ git commit -am f1
[feature eaf4121] f1
1个文件已更改,1个插入(+),1个删除( - )
$ git checkout master
转换到分支'master'
$ git merge -s我们的功能
由'我们的'策略合并。

现在我有类似的回购状态:

  $ git log file 
commit a965818706c47d065b81a994aeb5fc24cd77d001
作者:Anatoly Kupriyanov< kan.izh@gmail.com>
日期:Mon Oct 7 22:44:52 2013 +0100

c1
$ git checkout功能
转换到分支'功能'
$ git日志文件
commit eaf41212872d784d4e4e50e62167072d35b6167f
作者:Anatoly Kupriyanov< kan.izh@gmail.com>
日期:Mon Oct 7 22:49:02 2013 +0100

f1

提交a965818706c47d065b81a994aeb5fc24cd77d001
作者:Anatoly Kupriyanov< kan.izh @ gmail.com>
日期:Mon Oct 7 22:44:52 2013 +0100

c1

$ git branch --contains eaf41212872d784d4e4e50e62167072d35b6167f
*特性
master

因此,基本上,如果您从另一个分支进行合并,但还原合并提交中的任何更改对于该文件,内容不会更改,但合并的提交会显示在历史记录中。


I'm having an issue where git says a commit is merged, but the changes from the commit aren't in my working tree. To make things even weirder, git log --name-status 362dde7 tells me that the commit modified a file, but git log -- path/to/modified/file.java does not show the commit. For example:

Ensure that the commit in question exists on both the dev branch and feature branch.

$ git branch --contains 362dde74f142831c99820b999558a2e8f49f66e8
* dev
  feature

List the files modified by the commit.

$ git show --name-status 362dde74f142831c99820b999558a2e8f49f66e8
# commit summary... #
M       path/to/modified/file.java

Now when I do the reverse (list the commits that have modified the file) the commit isn't listed.

$ git log path/to/modified/file.java
# Commit 362dde7 isn't listed here

If I switch to the feature branch and follow the same steps, everything works as expected.

$ git checkout feature
$ git show --name-status 362dde74f142831c99820b999558a2e8f49f66e8
# commit summary... #
M       path/to/modified/file.java
$ git log path/to/modified/file.java
362dde7 Commit summary

Basically, the same commit exists on both dev and feature, but the working tree changes only show up when I have feature checked out. Does anyone have an idea as to why this is happening?

解决方案

$ git init so19234836
Initialized empty Git repository in /tmp/g/so19234836/.git/
$ cd so19234836/
$ echo "content created" > file
$ git add file
$ git commit -m c1
[master (root-commit) a965818] c1
 1 file changed, 1 insertion(+)
 create mode 100644 file
$ git checkout -b feature
Switched to a new branch 'feature'
$ echo "feature change"> file
$ git commit -am f1
[feature eaf4121] f1
 1 file changed, 1 insertion(+), 1 deletion(-)
$ git checkout master 
Switched to branch 'master'
$ git merge -s ours feature
Merge made by the 'ours' strategy.

Now I have similar state of the repo:

$ git log file
commit a965818706c47d065b81a994aeb5fc24cd77d001
Author: Anatoly Kupriyanov <kan.izh@gmail.com>
Date:   Mon Oct 7 22:44:52 2013 +0100

    c1
$ git checkout feature 
Switched to branch 'feature'
$ git log file
commit eaf41212872d784d4e4e50e62167072d35b6167f
Author: Anatoly Kupriyanov <kan.izh@gmail.com>
Date:   Mon Oct 7 22:49:02 2013 +0100

    f1

commit a965818706c47d065b81a994aeb5fc24cd77d001
Author: Anatoly Kupriyanov <kan.izh@gmail.com>
Date:   Mon Oct 7 22:44:52 2013 +0100

    c1

$ git branch --contains eaf41212872d784d4e4e50e62167072d35b6167f
* feature
  master

So, basically if you do a merge from another branch but revert any changes in the merge commit for the file, content is not changed, but merged commits appear in the history.

这篇关于为什么通过提交引入的更改不会显示在我的工作树中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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