GitHub pull request showing commits that are already in target branch

前端 未结 11 1045
孤城傲影
孤城傲影 2020-12-12 09:29

I\'m trying to review a pull request on GitHub to a branch that isn\'t master. The target branch was behind master and the pull request showed commits from master, so I merg

11条回答
  •  时光说笑
    2020-12-12 10:19

    To sum up, GitHub does not rebase the commit history automatically in pull requests. The simplest solutions are:

    Solution 1: Rebase

    Suppose that you want to merge into master from feature-01:

    git fetch origin
    git checkout feature-01
    git rebase origin/master
    git push --force
    

    If you are working on a fork then you might need to replace origin above with upstream. See How do I update a GitHub forked repository? to learn more about tracking remote branches of the original repository.

    Solution 2: Create a new pull request

    Suppose that you want to merge intro master from feature-01:

    git checkout feature-01
    git checkout -b feature-01-rebased
    git push -u origin feature-01-rebased
    

    Now open a pull request for feature-01-rebased and close the one for feature-01.

提交回复
热议问题