Question

I have three branches on remote (master, development, featurebranch). What I wanted is that when I push branch1, it should try and push it to the development branch, or any kind of branches I prefer. I've seen examples of what I should do like this

git push origin local_name:remote_name

But when I tried it, Git automatically merges the local branch to the remote branch. I wanted it to have a pull request on that branch. There's this nifty function on GitHub where I can just switch and select the branch that I wanted it to be merged:

branch selection on github

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?

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top