Continue working on a Git branch after making a pull request

GitVersion ControlGithub

Git Problem Overview


I've found myself in this situation a couple of times lately, and I'm not totally sure how best to handle it.

So I have a fork of a git repository that I'm contributing to. I keep my master branch synced with the upstream master branch.

When I want to work on a new feature, bugfix, etc, I create a branch from my master and do any work. When I'm done, I merge in any changes that have been made to upstream master in the meantime, and then send a pull request from my feature/bugfix branch to the upstream master.

Now, while I'm waiting for that pull request to be accepted, I want to work on something slightly different. However, the new feature work needs the bugfix/new feature that I just sent the pull request for. I need to build on it.

How do I branch/merge/handle branches in such a way that I can work on the continuation, while still being able to merge/pull request in my changes in a clean way once the first pull request is accepted into master?

This is all using Github, although I imagine the answer would be applicable to Git in general.

Git Solutions


Solution 1 - Git

Create a new branch feature2 based on the last commit to feature1. feature1 will not move forward any more, and can be merged.

feature2 can then be merged later (some people would argue to rebase feature2 on the commit where feature1 was merged into upstream, but personally i dislike rebasing).

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionIsaac Dontje LindellView Question on Stackoverflow
Solution 1 - GitmnagelView Answer on Stackoverflow