But is there a way that when I push my branch to a remote branch, the base branch is set to the remote branch I specified?
That means avoiding:
x--x--x (branch1) x--x--x
==> push ==> \
y--y--y (origin/remote-name) y--y--y--M
But rather get:
y--y--y--x--x--x
That is only possible if, before pushing, your branch1
has been rebased on top of origin/remote_name
:
git fetch origin
git checkout branch1
git rebase origin/remote_name
git push branch1:remote_name
Our scenario is like Master branch is the, let's say live app, every time we found a defect, we create a fix-branch (should be branched off the development branch), create our fixes and push the fix-branch to development branch first where testing and QA happens. Once finalized, push it back to master.
In your case, you need to rebase and push to a different branch, one which is not dev
, because dev
represents a different development effort, one of continuous modifications, as opposed as puctual fixes.
Create a release branch which represents the hot-fixes that you integrate one by one on top of master
(prod).
Each time you see a bug:
- create a branch for that
bug
, - fix the bug
- rebase the bug branch on top of the
release_branch
- push the
bug
branch for QA to review - once reviewed, push it to
master