skylize
skylize

Reputation: 1451

Sane way to continue working on local git repo while awaiting a pull request

I currently have master synced with upstream on github, and a working branch, which we can just call working. working is 1 commit ahead of master with an open pull request upstream.

I want to continue working on the same files, building on my committed changes, but plan to not append these to the current PR, instead waiting for upstream merge before submitting anymore changes.

If you had a repo in this state, what would you do next as far as branching, merging, etc., before making more changes, to hopefully make the next upstream rebase as painless as possible?

Upvotes: 2

Views: 1240

Answers (1)

AnimiVulpis
AnimiVulpis

Reputation: 2726

Option A:

Work on your branch (maybe create a new branch to lessen possible confusion) and as soon as the PR is merged rebase your work onto the updated master branch.

Option B:

If you are confident that the PR (I assume against master) will be accepted as-is you could do something like the following:

$ git checkout master
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'
$ git checkout -b future-master
Switched to new branch 'future-master'
$ git merge working

This should result in future-master having the same state as master will be in after the PR.

Continue working (maybe create a new branch for less confusion) and as soon as the PR gets merged you rebase your work:

$ git fetch origin
$ git rebase origin/master

The amount of merge conflicts should be minimal (in most cases zero)


Side note: If your working branch is really only 1 commit ahead. I don't think that Option A is any better than the simpler Option B.

For more complicated cases it might help. ymmv

Upvotes: 2

Related Questions