Reputation: 11
Assume I have three branches master,develop and release in remote repository.
ae3r4...
), I can merge using one of the three options that Github provides
233f1d...
).I don't want that. When I merge a new commit in master, I want the same commit to be present in develop and release. How do I do it? How is this generally done in organisations to point to the same commit from different branches, like a bash script or from the UI? Coz, whenever we merge a commit to master this has to happen, so it'd be helpful if the solutions takes into account the maintenance part too.
Upvotes: 1
Views: 1753
Reputation: 113
two branches can point to the same commits. However in the case of dev
the branches don't share the same history, so you have to tell Git it's okay to basically squash the existing dev
branch.
This will point your dev
branch to whatever your local master is pointed to:
git push origin +master:dev
Keep in mind, it will squash whatever dev used to point to on the server. The +
sign tells Git it's okay to squish stuff.
Upvotes: 0
Reputation: 1329232
In all of the options a new merge commit is created
There is one option where potentially no new merge commit is created.
See "Rebasing and merging your commits"
When you select the
Rebase and merge
option on a pull request on GitHub, all commits from the topic branch (or head branch) are added onto the base branch individually without a merge commit.Pull requests with rebased commits are merged using the fast-forward option.
That means: if you first rebase locally your PR branch on top of origin/master, and force push it, then:
Rebase and merge
will not generate a new commit.But that approach works for a topic
branch, not for a branch used by many for integration (like "develop
").
And that would be for PR from topic branches to master
: it is not a best practice to merge master
to other branches (PR or not).
That is why I recommend the use of gitworkflow
(one word): see more at rocketraman/gitworkflow
.
Upvotes: 1