本文介绍了Git:如何在没有重复的PR合并提交的情况下同步我的本地和上游存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将自己的请求请求功能分支合并到本地存储库的master分支上.但是,如果上游维护者合并了我的请求,那么我将不得不合并另一个合并提交. Git并没有意识到我之前已经合并了同一个分支,所以我对同一个分支有2个合并提交.

你们如何在没有重复合并提交的情况下同步本地和上游存储库?

解决方案

如果我对您的理解正确,那么您的状态或多或少是这样的:

(黑色=上游,蓝色=功能,绿色=主)

因此,当您将上游合并到master中时,您会得到:

您需要一个本地集成分支和一个上游同步分支.您可以使用本地集成分支来合并功能(现在在master中正在执行的操作).然后,您可以使用upstream跟踪上游合并.

进行PR并在上游被接受时,您会在upstream分支中将其作为合并接收,而本地集成分支(在这种情况下为master)不会与合并 feature分支

此后,您可以在master中安全地合并upstream,并且在master中获得一个合并.或者,如果您确实不想进行任何合并,则可以使用重新设置.. >

I need to merge my own pull request feature branch onto my local repo's master branch. However, if the upstream maintainer merges my pull request, I'll have to pull in another merge commit. Git doesn't realize that I already merged the same branch before, so instead I have 2 merge commits for the same branch.

How do you guys sync your local and upstream repositories without duplicate merge commits?

解决方案

If I understand you correctly, your status is more or less this:

(Black = upstream, blue = feature, green = master)

So, when you merge upstream into master, you get this:

You need a local integration branch and an upstream-synced branch.You use the local integration branch to merge your features (what you are doing in master right now).And you use the upstream to keep track of upstream merges.

When you make a PR and it's accepted upstream, you receive it as a merge in your upstream branch, while you local integration branch (master in this case) is not merged with the feature branch

After that you can merge upstream safely in master, and you get one merge in master. Or if you really don't want any merges, you can use rebase.

这篇关于Git:如何在没有重复的PR合并提交的情况下同步我的本地和上游存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 06:06