- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
假设我有 2 个分支,master
和 other
。
我进入 other
分支,添加 2 个文件,提交并推送。
现在我进入 master
分支,将文件添加到不同的目录,然后提交它们。然后我 merge other
。
问题是我在 other
中添加的文件没有显示出来。 Git 说它是最新的,但它不是!文件丢失。
如何强制 master
添加 other
中的文件或以某种方式手动添加它们?
为 Karl 编辑:
据我所知,我执行了以下操作,尽管未显示的更改已持续数周。我刚刚意识到他们今天不在。
$ git branch
*other
master
$ git add .
$ git commit -m 'cool new features'
$ git push origin other
$ git checkout master
$ git merge other
$ git add .
$ git commit -m 'merged cool new features from other'
$ git push origin master
我继续访问 Github,但那里没有文件。其他文件已提交并显示,但两个文件夹没有匹配的内容。这些文件存在于 other
中,但不存在于 master
中。澄清一下,这些文件不是新的。但我认为如果文件不存在, merge 至少会将文件复制到 master
!
最佳答案
有点晚了,但是对于发现这个问题的其他用户,我将描述一个 AJcodez 观察到的问题会发生的情况。如果你做一个 git checkout master; git merge other
,在此期间或之后您删除 master
中的一些新文件(并且可能会忘记该事实),然后执行 git checkout master; git merge other
,那么"new"文件将不会重新出现在 master
中,因为它们不是新的。 Merge 只关心与 merge-base 相关的更改,merge-base 是可通过两个分支访问的最年轻的提交。在第二次 merge 期间, merge 基础与第一次 merge 期间不同,在所描述的场景中,第二次 merge 期间的 merge 基础是第一次提交时 other
的提交 merge 。如果 other
此后没有更改新文件,则 master
中的删除是最新的更改,因此删除新文件将是第二次之后的状态 merge 。
如果这看起来不方便,您可以通过创建一个临时分支(我们称之为 merge_branch
)绕过它,使用 --squash 将
,提交, merge 到other
merge 到其中master
,删除临时分支。这可能不是理想的解决方案(例如,已经解决的 merge 冲突可能必须再次解决),但原来的情况可能已经是错误的结果。这是我在代码中的意思:
git log other # find the commit where 'other' originally branched off
git checkout -b merge_branch COMMIT_ID # go there & create branch
# without '--squash', the following merge would simply be a fast-forward
# merge and wouldn't solve our problem, because 'merge_branch' would then
# point to the same commit as 'other' and so the later merge into
# 'master' would produce the same unsatisfactory result.
git merge --squash other # does not create a new commit by itself
git commit # better add an explanation for what you did and why
# 'merge_branch' now contains everything you did in 'other' since it
# branched off from 'master', but squashed into a single new commit
git checkout master
git merge merge_branch
git branch --delete merge_branch
关于Git master 分支 merge 后根本没有新文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13618108/
我遇到了一个似乎很独特的问题。我的 NSUbiquitousKeyValueStore 在模拟器中的启动之间根本不起作用。也就是说,我什至不是在谈论 iCloud 同步或类似的东西,我无法让它通过下面
首先,我使用的是 WiX 版本 3.5.2519.0,但我也在最新的 3.6 版本上测试了它,结果相同。 我很难确定 PatchFamily 究竟能过滤掉 torch 生成的差异的某些部分。按照手册中
我可以获取要呈现的“帮助主题”标题,但无法获取我定义的任何FIXTURES。 {{#each model}} 中的任何内容都不会渲染。这是我第一次使用 Ember,所以任何东西(字面意义上的任何东
我一直在尝试设置custom ajaxTransports for jQuery在我们的产品的某些场景下缩短某些工作流程。然而,我在让这些传输受到尊重方面取得了零成功(而我有很多工作 custom a
为什么纯无类型 lambda 演算经常被描述为无法使用? 有了合适的函数库,它会不会与任何其他函数式语言大致相同? 最佳答案 速度不是大问题。例如,您可以决定使用教堂数字但优化实现,以便像往常一样表示
我是一名优秀的程序员,十分优秀!