我找到了一个方法,可以将文件从一个分支整体复制到另一个分支:
请注意,如果您认为这个问题是这个的重复,请注意上面我链接的那个问题^^,下面的内容解释了我想要的不同功能。
$ 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
来取消暂存的更改,但我希望一次性得到想要的结果,不需要第二步操作。如何在不暂存文件的情况下从另一个分支复制文件?
git show
(2次)。 - phd