Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to compare my uncommitted source against an arbitrary history item in git through VS IDE?

With our workflow, which is a slight modification of gitflow, we will have a local branch with our feature. We then do our feature/fix on that branch, push it to the server, have it reviewed and then merge it to the trunk.

While working, I like to see what changes I've made from where the branch started. However, if I commit some changes, I can no longer see my changes from that point. It would be nice to see the changes from the point of the branch to ensure that all my changes are valid, but I can only see the changes to the last commit via Compare with Unmodified....

As a workaround, I would have thought that I could at least look at the history of a file and see the changes from my current to one of the ones listed there, via the context menu, but that option isn't available either. You can only compare against 2 existing commits.

Seems that I can only see the changes from my HEAD to an arbitrary point in the history from the command line. Am I missing some esoteric way of seeing my uncommitted code against an arbitrary point in the history? Or does this feature not exist?

EDIT

Talking to others and given the only response on this question, it would appear that this is not currently possible.

In which case, I've created a uservoice item here to have this feature added to Visual Studio, and am asking others to please upvote it so that they will consider it for their next release.

Thanks

like image 555
Adrian Avatar asked Dec 01 '17 16:12

Adrian


1 Answers

Lets go from the console towards IDE

Console

Well, of course, you can do lots of stuff in console:

  • Comparing working tree (current code state) with any point in history:git diff COMMIT_HASH
  • Finding the closest common ancestor: git merge-base feature_branch parent_branch
  • Combining together: git diff $(git merge-base feature_branch parent_branch)

Diff tool

You can configure preferred difftool, so launching git difftool $(git merge-base feature_branch parent_branch) in console will show changes for each file in specified graphical app. I didn't get used to it, so won't go into details, but there is a lot of info in the net.

Git interface application

Lots of graphical applications almost completely wrap console commands including your case. I do love console, but prefer doing code diffs/merges in GUI. I use free and open source TortoiseGit exactly for your case by right-clicking in project folder and selecting TortoiseGit > Diff with previous version. Comparison base can be set by hash directly or by choosing entry from log list, working copy is denoted with special "00000000" hash. It's very handy to have list of all changed files in one place, opening diff for any chosen file allows modifying it on the fly. Everything you want except for IDE autocomplete.

MSVS

It would be a dream to have everything in one place, but IMHO even the latest visual studio provides very limited support of git commands. That happens for a good reason: git is reeeeally comprehensive, so even apps fully dedicated to wrapping git commands can't do it completely and consistently. Visual studio allows performing basic everyday tasks, but any a bit more specific query is out of its scope.

like image 76
nnovich-OK Avatar answered Oct 06 '22 01:10

nnovich-OK