git pr - 拉取后将 pr 中目标分支中已经存在的其他更改显示为新更改

问题描述 投票:0回答:1

远程单反: PR 显示你的更改 + 其他团队成员的更改,而不是只显示你在 PR 中的更改(在使用 git pull 在本地解决冲突后)

重现问题的步骤:

  1. 在 master 分支上 =>
    git checkout -b "feature"
  2. 做你的功能(而其他团队成员将代码推送到同一区域)
  3. git pull origin master 
    (获取更改并解决冲突)
  4. git push origin/feature
    并打开 PR

预期结果: git PR 应该只显示 your 更改

实际结果: git PR 显示你的更改 + 其他团队成员更改已经在 master 分支中

这是我的 git 配置:

init.defaultbranch=main
branch.autosetuprebase=always
branch.master.rebase=true
branch.upstream.rebase=true
pull.rebase=true
rebase.autostash=true

我该如何解决这个问题?

git atlassian-sourcetree
1个回答
0
投票

更安全的命令序列是:

# work on feature branch
git fetch
git rebase origin/master
git push -u origin feature

如果你的 PR 目标是

master
,那么只有你的提交应该是可见的。

© www.soinside.com 2019 - 2024. All rights reserved.