简体   繁体   中英

View the history of a file while trying to merge, showing both branches

I am trying to handle merge conflicts. Rather than seeing the changes on each branch, as tools typically show, what I really want to see is the tree of the file, starting from the nearest common ancestor, then showing the commits that changed the file, with the option to drill down into the changes from a particular commit if necessary.

Critically, I need to see the commits from each branch that leads up to the prospective merge, not just from my current branch. The accepted answer to View the change history of a file using Git versioning is getting close to my ideal. But to actually use it, I have to create a dummy repo, actually complete the merge in said dummy repo, then apply the accepted answer there to the dummy repo. I'm wondering if there is an easier way.

I am not sure it will quite answer, but you can do the following logs:

git log --oneline --graph branch1 branch2 # Show the graph of both branches (including common parents)
git log --oneline --graph branch1...branch2 # show the graph of commits for the commits which are either in branch1 or in branch2 but not both (note the 3 dots)

For most content conflicts, having config set with merge.conflictStyle=diff3 is more than enough. There might be cases where you might have to dig deeper but having the common ancestor and the two conflicting pieces of code is enough to figure out what's going on.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM