I have a git branch (the mainline, for example) and I want to merge in another development branch. Or do I?
In order to decide whether I really want to merge this branch in, i'd like to see some sort of preview of what the merge will do. Preferably with the ability to see the list of commits that are being applied.
So far, the best I can come up with is merge --no-ff --no-commit
, and then diff HEAD
.
Once you've identified conflicting sections, you can go in and fix up the merge to your liking. When you're ready to finish the merge, all you have to do is run git add on the conflicted file(s) to tell Git they're resolved. Then, you run a normal git commit to generate the merge commit.
The git pull command is actually a combination of two other commands, git fetch followed by git merge . In the first stage of operation git pull will execute a git fetch scoped to the local branch that HEAD is pointed at. Once the content is downloaded, git pull will enter a merge workflow.
Look at the answer text: "If there's more than one `parent' line in the output, you found a merge." In other words: grep. And if the commit message has a line starting with "parent", you can't (easily) do that.
git log ..otherbranch
git diff ...otherbranch
gitk ...otherbranch
Empty string implies HEAD
, so that's why just ..otherbranch
instead of HEAD..otherbranch
.
The two vs. three dots have slightly different meaning for diff than for the commands that list revisions (log, gitk etc.). For log and others two dots (a..b
) means everything that is in b
but not a
and three dots (a...b
) means everything that is in only one of a
or b
. But diff works with two revisions and there the simpler case represented by two dots (a..b
) is simple difference from a
to b
and three dots (a...b
) mean difference between common ancestor and b
(git diff $(git merge-base a b)..b
).
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