Fabian Zeindl Fabian Zeindl - 1 month ago 6
Git Question

Github: How do I keep clean branches for PRs while merging them locally?

I have a fork of a repository on Github.

I'm creating all sorts of little patches. For each patch I create a local branch and submit a PR.

Now I also need all these patches merged together for a local build which includes all of the features.

  • Should I merge them into my local master? If so, where do I branch off in the future?

  • Can I somehow base a new branch B (new code) on another branch A (adjusted buildsystem) I submitted a PR for, and still keep those separate? Meaning that I submit a PR for B without the contents of A, and A separately.


I would create a separate branch and merge all your branches into it to do your local build. If you create more features or just update one of the branches, you can merge them to that branch too.

You could also use your local master to do that if you prefer so. Afterwards you can use git checkout -b new-branch origin/master to create new branches, which would use the master from the remote repository named origin as the base for the new branch.

It is not possible to create a pull request for just a part of the changes contained in a branch. So after merging A to B (or creating B based on A), the changes from A would also occur in the Pull request for B.