Question

Say, from my original master, I made certain change to it and committed the change at time t1 I then pushed this to github (calling it branchA). Then I made some other change and committed it at time t2. I don't want to push this to branchA, but I want to push it to another branch called branchB.

Is it possible to list branchA as the prerequisite for branchB so that when I do a pull request, the diff in branchB does NOT include the changes committed prio to t1, in other words, the diff in branchB should only show the diff between branchA and branchB?

Bazaar/Launchpad offers this option, but I haven't been able to find the similar feature in Github. (I'm new to git, so maybe this isn't something they do in Github?)

Was it helpful?

Solution

That means you have:

Local Repo                  Upstream (GitHub Repo)

 .--.--o--x--y branchA   <====> o--o--x branchA
(master)

But you want:

.--.--o--x branchA      <====> o--o--x branchA
(mast) \
        y branchB        => you can push now

That means you need first to rebase onto o what comes after x (t1) in order to build branchB locally, before pushing it to your fork.

git checkout branchA                
git branch branchB                  # creates branchB where branchA currently is
git reset --hard origin/branchA     # reset branchA to x
git rebase --onto master x branchB  
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top