【发布时间】:2019-09-25 12:36:15
【问题描述】:
我有found 如何将文件从一个分支批量复制到另一个分支:
编辑请注意,如果您认为此问题与this 重复,请注意我在上面链接的问题^^,并且 以下内容解释了我想要的不同功能。
$ git checkout directory/somefile.php feature-B
但是,此解决方案已经对更改进行了分阶段:
$ git status
On branch feature-A
Your branch is up-to-date with 'origin/feature-A'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: directory/somefile.php
但我不想添加所有更改。我想做一个add -p 并采取大部分但不是全部的更改。我想要的是这样的:
$ git status
On branch feature-A
Your branch is up-to-date with 'origin/feature-A'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: directory/somefile.php
no changes added to commit (use "git add" and/or "git commit -a")
当然,我可以通过git reset 取消暂存更改,但我希望第一次得到我想要的,无需第二步。
如何在不暂存的情况下从另一个分支复制文件?
【问题讨论】:
-
@phd 您链接的这个问题实际上是我在问题开始时链接的那个问题,我的问题阐述了我希望与该问题的答案不同的功能。
-
是的,它包含答案:
git show(2 次)。 -
@phd 并且它从未说过该方法将复制但不会暂存提交。换句话说,它没有回答我的问题;它将它作为
git copy...的替代品呈现,没有任何功能差异的迹象,因此用户会假设它的行为方式相同。如果有人在谷歌上搜索我的问题的答案,这些答案中没有任何信息表明它符合他们想要的行为。 -
@phd 搜索中的哪个问题特别包含答案?
-
@phd 不是重复的。这是一个更精确的问题和答案。
标签: git