Search code examples
gitgithubgit-commitgit-push

All Commits From Every Branch Displayed During Pull Request on Github


Every time I push up code from my working branch that was either created by branching off another branch or branching off master, and I create a pull request and then all commits I have ever made show up on the pull request. These commits go 2 months back and are from multiple branches Anyone know why?


Solution

  • Before pushing your branch from which you want to make a pull request, first:

    • fetch from the original repo (the one with the master branch you want the maintainer to accept your pull request)
    • rebase your branch on top of that fetched master branch
    • then force push to your fork, and do your pull request: you will only see your commits

    That is

    cd /path/to/local/forked/repo
    git remote add upstreamm https://url/original/repo
    git fetch upstream
    git checkout my-feature-branch
    git rebase upstream/master
    git push -u origin my-feature-branch # possibly add --force