Is it possible to determine if two git branches will merge cleanly without affecting the working directory? -


If you are able to move faster, you can set the git with merge-base, but to decide For whether the two branches are merged with some strategy without actually merge? I know about GIT merge --no-commit --no-ff $ branch , but it affects the work directory, which I would like to save because it is part of a webservice.

There is no built-in method; To merge requires a work tree if the merge will work (in the normal case), that means the strategy should be tried and what is to see what happens.

You can examine the trivial case: Find the merge base that both branches do not touch the same file, and then check whether the git diff --name-only $ merge_base branch A And anything in the git diff --name-only $ merge_base branch B is anything.

Otherwise, you will need a work tree to try merge. You can easily create each other - either clone the repository, or save space, just create a work tree script (from git.git's contrib directory) can help with this; It creates a new repo whose .git directory is full of syminks back from the original one. Just be careful that in the new working directory, you do not modify the branch that is checking the original repo - they will exit from the sync, in the same way that currently spoils things by pushing into the check-out branch.


Comments