简体   繁体   中英

Force git to display differences between branches in editor like a merge conflict

I have two git branches I'm working on, let's call one problem-fix and the other problem-fix-dev . The dev branch is connected to a personal remote pipeline I'm working on, so I've been including all sorts of debugging and logging statements for testing purposes. Now that I've finished my fix, I want to merge it into problem-fix , but obviously don't want to include the various printing and logging code.

I could go through the code and just delete all the undesirable lines, but that would be very tedious. And it won't be as simple as deleting all lines that begin with print for various reasons. Additionally, I can't just git rebase and selectively drop commits, since many of the commits I've made have both undesirable printing lines as well as important fix code.

So my question is: is there a way to force git to show differences between branches in editor, ideally with the merge conflict syntax? While I'm sure there are no actual existing conflicts, my life would be made a lot easier if each change was highlighted in the editor line by line.

Alternatively, I'm using VSCode. So if there is a nifty extension or plugin that can accomplish the same thing, that would be fine.

Thanks

This is what you could do:

  1. Undo all the commits but keep the changes in the working branch (eg git reset head~4 )
  2. Review your changes and undo all unneeded changes (I personally use TortoiseGit for this, there I could undo files or lines in files - it visible with a two panel merge view)
  3. Create a new commit

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