In Visual Studio (if you're using a git repository) you can right-click a modified file and select "Compare with unmodified". There you can see a diff in which you can edit the current version of the file. To clarify: You can edit your current uncommitted changes in source files, in a diff view compared to the latest commit. To contrast that, comparing 2 commits in diff view only shows you read-only copies of these files in temp folder which you cannot edit.
But when you're looking at a diff between the current revision and some older revision (by selecting the top commit and one of the older ones with Ctrl-click and in the right-click menu selecting "Compare commits...") you cannot edit the files from the current revision.
Is there a way to enable editing the current revision files in diff view in Visual Studio when comparing any older revision (not just the previous one) with the current revision?
Side note: One weird trick which developers hate is resetting to the desired older revision with "keep changes" and making a commit, thus making it possible to "compare with unmodified" as if it was a previous commit. But this is hacky and undesirable.
You can run the git diff HEAD command to compare the both staged and unstaged changes with your last commit. You can also run the git diff <branch_name1> <branch_name2> command to compare the changes from the first branch with changes from the second branch.
The git diff command shows the differences between the files in two commits or between your current repository and a previous commit.
"git diff" always show the difference between two commits (or commit and working directory, etc.).
Diffing is a function that takes two input data sets and outputs the changes between them. git diff is a multi-use Git command that when executed runs a diff function on Git data sources. These data sources can be commits, branches, files and more.
This is unfortunately not currently supported when diffing two versions from the VS 2017 Git History tool window, even if one of the versions is the current workdir version. We also don't currently have the ability to choose a specific version with which to do the diff from the Changes page. I will add this to our backlog for consideration for a future Visual Studio release.
As you noticed, the diff is sometimes editable from the Git Changes page in Team Explorer. Here's a summary of how we determine if the diff window will be editable.
Hope this helps, and thanks for raising this question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With