我注意到一个问题,每次我在 bitbucket 中接受 pull 请求并将功能分支 merge 到开发分支,然后返回到我的命令行并从中执行 git pull
在我的开发分支中,git 响应:
Your branch is ahead of 'origin/Dev' by 2 commits.
(use "git push" to publish your local commits)
我已经尝试过 git pull
、git pull origin
、git pull origin Dev
、git fetch
, git fetch origin
等
我该如何解决?
编辑:
如果我 git push
清除状态,它会推送带有以下消息的提交:
Merge branch 'Dev' of https://bitbucket.org/foo/bar into Dev
我通过 bitbucket 执行的 pull 请求 merge 有一条提交消息:
Merged in feature-branch-name (pull request #3) Some changelist commit message here
而且它们都带有相同的时间戳。尽管我可能会在 15 分钟后 git push
。
最佳答案
在您的开发分支中有两个提交(其中包含您之前使用 git commit 或 git merge 提交的本地文件更改)尚未推送到 origin/Dev。
解决它的最佳方法通常是“使用“git push”,它将您的本地提交复制到远程存储库,以便其他人可以 pull 它们。
如果你愿意
- 摆脱这两个提交(及其所有更改)
- 摆脱本地工作树文件更改
- 返回原始/开发的确切状态
使用这个命令(在开始之前确保你在你的开发分支中)
git reset --hard origin/Dev
在此命令结束时,您的 dev/branch 和 origin/Dev 以及跟踪的本地文件将全部匹配。
关于Git 响应 "Your branch is ahead of ' origin/Dev' by 2 commits"after merging a pull request through Bitbucket,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37575648/