The remote has two branches: mainline
and release-x
.
I pushed one recent feature from my local branch to remote mainline
,
But I don't how to also push this feature into the release-x
branch.
Any suggestion would be appreciated. Thank you.
The remote has two branches: mainline
and release-x
.
I pushed one recent feature from my local branch to remote mainline
,
But I don't how to also push this feature into the release-x
branch.
Any suggestion would be appreciated. Thank you.
You have multiple possibilities:
At first, make sure that you have the branches locally. This can be done by calling git pull origin mainline
and git pull origin release-x
.
Go to release-x
branch(check out a local copy) and copy the commit to that branch using git cherry-pick <commit hash>
Don't forget to execute git push origin release-x
after that.
You can also merge all changes from mainline
to release-x
by checking out release-x
and runing git merge release-x
or git merge <commit hash>
if you want to merge the difference until a commit in mainline
.
Don't forget to execute git push origin release-x
after that.
If you want to copy all changes from mainline
to release-x
, and release-x
is 0 commits behind mainline
, you can also push mainline
to release-x
using git push origin mainline:release-x
You can also completely overwrite the remote content of release-x
with the content of mainline
using git push -f origin mainline:release-x
. But this will remove all changes made to release
that are not committed in mainline
. If you want to do that despite this, I suggest you to use --force-with-lease
as it does not overwrite the remote if another person pushed to it without you knowing.
Specify the full remote and branch to push to. The remote you cloned from is origin.
git push origin release-x
See "Pushing to Your Remotes" in Working With Remotes in the Git Book.
This will only work if your local branch and release-x
have a common ancestor. It may not be the best way to manage your release branch, it depends on your release process.