Before anything else, I\'m just new to git branching. I wasn\'t aware that every feature branch should be branched out from master
and only use the pre-requisit
Is there a way to rebase
feature-2
tomaster
without the need to push again the commits offeature-2
Not really, considering a rebase will replay the commits of feature-2 on top of master, given you this:
M1 -- M2 -- M3 -- M4 -- M5 [master]
\ / \
A1 --- A2 [feature-1] A1' --- A2'
\
B1' -- B2' -- B3' [feature-2]
As the '
sign indicates, all the commits have changed (their SHA1 is different).
Since A1
and A2
were already merged into master
, a better rebase would be
git rebase --onto master A2 feature-2
That would get:
M1 -- M2 -- M3 -- M4 -- M5 [master]
\ / \
A1 --- A2 [feature-1] B1' -- B2' -- B3' [feature-2]
You should git push --force
that newly revised feature-2
branch in order to update your pull request.
A forced push should update a pull request in Bitbucket since it supports such a push since Q4 2012 (issue 4913).
A forced push won't have any other adverse effects, considering you are pushing a branch to your fork where, presumably, you are the only one to push updates.
Since the pull request will automatically updates itself with the new history of feature-2
, that won't compromise said pull-request.