Git: Don't push merged/pulled branches

Refresh

April 2019

Views

35 time

1

I am looking for a solution to a problem I seem to be running into more and more working on distributed projects that change quickly. Here is the problem statement:

There are a number of developers working on improving a common code base in github that uses the master branch. Each one spins up their own fork/branch and develops their features independently. In this scenario these developers are making a significant change to master so the split up the work. Each one takes a set of independent fixes that they resolve and push back. Each would create their branch/fork in a typical manner: git checkout -b featuredev master

Lets assume that developer 2 finishes his code and creates a pull request that everyone agrees is correct but it is delayed being merged into master due to lack of resources. Developer 1 wants to get these fixes so he can use them. So he pulls them into his current development branch using something like git pull /ref/123/head to get the code into his current repo.

Developer 1 finishes his work and now wants to push his fixes back to the server. If he does a git push git will correctly push his source into the pull request and it will also include all of the commits from developer 2. So now when developer 1 creates a PR it has all of his commits and all of developer 2's commits in it which are encompassed in another pull request. Is there a way for developer 1 to push just his code changes and not the commits from developer 2? Am I generating a scenario that doesn't matter? Right now the only way I have found to isolate developer 1's changes is to go through an annoying rebase operation to remove developer 2's commits from the branch before doing a push.

0 answers