Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 合并到分支并签出而不更改文件_Git - Fatal编程技术网

Git 合并到分支并签出而不更改文件

Git 合并到分支并签出而不更改文件,git,Git,假设我在主分支上,我想防止我的IDE(例如Visual Studio)在执行此操作时(不必要地)重新加载文件: git checkout -b feature/myfeature <do my changes, validate the result => great I want them back in the master-branch that HAS NOT CHANGED in the meanwhile> git add -A; git commit -am 'm

假设我在主分支上,我想防止我的IDE(例如Visual Studio)在执行此操作时(不必要地)重新加载文件:

git checkout -b feature/myfeature
<do my changes, validate the result => great I want them back in the master-branch that HAS NOT CHANGED in the meanwhile>
git add -A; git commit -am 'my changes';
git checkout master
git merge feature/myfeature
git签出-b功能/myfeature
太好了,我想让它们回到主分支中,而主分支在此期间没有改变>
git-add-A;git commit-am“我的更改”;
切换到主分支
git合并功能/myfeature
在合并并导致目录树中的文件发生更改之前(在这种快进的情况下),如何在不先“签出”主分支的情况下执行此操作

x --- x --- A <--(master)
如果
master
确实是
分支的祖先
/
,那么这将快速推进它。如果出于某种原因,它不在
分支机构
/
头部
的位置,它仍然会被移动。但只要您没有
pull
ed更改,就应该可以了

更安全的解决方案是在单独的工作树上签出master来进行合并

git worktree add path/to/new/worktree/root master
cd path/to/new/worktree/root
git merge branch

您没有对
feature/myfeature
做出任何承诺,因此它与
master
相同。我不知道您正在尝试执行什么操作。当您签出分支时,目录树将发生更改,因此visual studio将检测到。我认为您可以执行前面讨论过的快速合并@JakubMatczak添加了提交以进行澄清
git branch -f master
git worktree add path/to/new/worktree/root master
cd path/to/new/worktree/root
git merge branch