Once I have that list, I can use other file comparison tools to scout things out further. The solution I have been searching for is how to have git spit out a list of files that have been changed in both branches that will be merged together in the future, relative to some common ancestor. I don't want to do a merge, I want to identify potential problems before I merge - problems that auto-merge might hide from me. I do not want to use the git merge command as the precursor to reviewing conflicting files. Likewise, " git outgoing" shows what would be pushed if you were to run " git push". (Though, since you've already fetched, the merge could be done directly.) You may then (optionally) run " git pull" to actually merge. Outgoing = log then you can run " git incoming" to show a lot of changes, or " git incoming -p" to show the patch (i.e., the "diff"), " git incoming -pretty=oneline", for a terse summary, etc. Incoming = "!git remote update -p git log symmetry, the following alias can be used to show what is committed and would be pushed, prior to pushing: # what would be pushed (currently committed) # fetch and show what would be merged (use option "-p" to see patch) otherbranch", you can add the following to ~/.gitconfig. Many answers omit the fetch to be done first before "previewing" the merge this is an alias that combines these two steps into one (emulating something similar to mercurial's hg incoming / outgoing) Beware.Īdding to the existing answers, an alias could be created to show the diff and/or log prior to a merge. The conflict markers can be quite different depending on circumstance (deleted vs modified, etc), which makes it hard to grep, too. User makes a good point: this makes it unsuitable for scripting, because you can't easily catch that from the status code. If you would get merge conflicts, they will show up with the usual conflict markers in the output, e.g.: $ git merge-tree $(git merge-base a b ) a b (thanks to David Normington for the link) It also doesn't colorize the output or use your pager, so the full command would be: git merge-tree $(git merge-base master develop) master develop | colordiff | less -R To truly see what would change in the master branch if you merged develop into it, right now: git merge-tree $(git merge-base master develop) master developĪs it's a plumbing command, it does not guess what you mean, you have to be explicit. past merges which already bring some of the outstanding changes into your target branch, or cherry-picks doing the same. Most answers here either require a clean working directory and multiple interactive steps (bad for scripting), or don't work for all cases, e.g. If you're not ready to merge, use the safer way above. If the merge is successful, you cannot abort it (only reset). If git reports conflicts (and ONLY IF THERE ARE conflicts) you can then do: git merge -abort Strategy 2: When you definitely want to merge, but only if there aren't conflicts git checkout mybranch You don't need to bother "aborting" the merge, and you can go back to your work - simply checkout 'mybranch' again and you won't have any merged code or merge conflicts in your branch. That way you can simply throw away the temporary branch if you just want to see what the conflicts are. However, if you want to ensure you don't mess up your current branch, or you're just not ready to merge regardless of the existence of conflicts, simply create a new sub-branch off of it and merge that: Strategy 1: The safe way – merge off a temporary branch: git checkout mybranch This particular syntax feels clean and simple to me. I've found that the solution the works best for me is to just perform the merge and abort it if there are conflicts.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |