Git still confuses me from time to time!
I have a staging and a master branch. Usually development occurs on the staging branch, which gets merged into master periodically.
However some commits have been made directly to the master branch. This means that the updates are missing from the staging branch.
How to I bring my staging branch back up to date with the master? Am I right in thinking merges should always occur in one direction (i.e. staging > master) and the merging master > staging is not the way to go?
You can undo a Git merge using the git reset –merge command. This command changes all files that are different between your current repository and a particular commit. There is no “git undo merge” command but the git reset command works well to undo a merge.
On the command line, a simple "git merge --abort" will do this for you. In case you've made a mistake while resolving a conflict and realize this only after completing the merge, you can still easily undo it: just roll back to the commit before the merge happened with "git reset --hard " and start over again.
I think it is a perfectly reasonable process to merge master
into staging
every now and then. This brings staging
up to date with the latest patches in master.
You can keep developing on staging
after that, occasionally bringing it up to date again with a merge.
When staging
has reached a stable state, you merge it to master
.
Merging between branches does not have to be unidirectional, nor does it have to be a one-time deal.
(The above is, of course, not the only possible branching strategy. See this for an example of a more advanced model)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With