为什么git会选择尚未合并的更改?
在我的布兰卡:为什么git会选择尚未合并的更改?,git,bitbucket,Git,Bitbucket,在我的布兰卡: git add -u git commit -m "fix weird issue" git push origin origin/BranchA 在bitbucket中: 创建新分支,从主分支 在命令提示符中: git fetch git checkout -b origin/BranchB git pull -u origin origin/BranchB //Updating 3 files, fast forward... git status // everythin
git add -u
git commit -m "fix weird issue"
git push origin origin/BranchA
在bitbucket中:
创建新分支,从主分支
在命令提示符中:
git fetch
git checkout -b origin/BranchB
git pull -u origin origin/BranchB
//Updating 3 files, fast forward...
git status
// everything is clean
3个文件在本地显示,即使BranchA尚未合并到master。为什么?更好的顺序是:
git add -u
git commit -m "fix weird issue"
git push -u origin branchA
git fetch
git checkout -b branchB origin/branchB
无需最后拉取假设您在
BranchA
上并且没有切换分支,git pull-u origin origin/BranchB
从origin
远程获取origin/BranchB
,并将该分支合并到当前分支,BranchA
。由于BranchB
和master
指向相同的提交,您现在在BranchA
中有了“master
内容”。你是有意的吗?还有,当我签出-b origin/BranchB时,您为什么在git pull
中使用-u
标志?@Jubobs我切换到BranchB。我做了一个git pull-u来跟踪遥控器的拉/推操作,所以你可以只写git pull
,但为什么最终拉取BranchA未合并的更改,基本上是我的问题。@doorfly这就是为什么我不做最终拉:我不想合并任何东西,只需基于新的和从源站获取的branchB启动一个本地分支。那么pull实际上进行了合并,包括从master提交到B的分支?即使A的更改尚未合并到master?@doorfly,pull是一个fetch加上一个merge。在这里,您根本不需要拉,因为您已经进行了提取。从master进行合并,包括从其他分支提交?这将是BranchA的Commission进入BranchB的唯一原因。