1

I have a file Staged, the text editor track changes margin is not appearing: enter image description here

But if I unstage it, these track changes marks will appear on the margin: enter image description here

Is there any way I can change it to always show the changes on the margin, even if the file is staged?

sergiol
  • 4,122
  • 4
  • 47
  • 81

1 Answers1

0

There does not appear to be a way to do this. I have a feeling its due more to how git add and/or git diff works than it is a Visual Studio problem. Visual Studio Code exhibits the same behavior as well.

I think it is because when you stage an item, it is no longer within your working directory, but rather now in the staging area (or index). I came across this answer which lead me to the book Pro Git. In this book, for git diff (see the Git Basics chapter), it states the following:

It’s important to note that git diff by itself doesn’t show all changes made since your last commit — only changes that are still unstaged. If you’ve staged all of your changes, git diff will give you no output.

This goes back to when I said it might be due to have git add and git diff works. Visual Studio is essentially doing a git diff to determine the modified lines in your file. And since the lines of code in question are now staged (git add'ed), git diff can no longer display the changes.

Timothy G.
  • 6,335
  • 7
  • 30
  • 46
  • I don't know what Visual Studio is doing behind the scenes, as I came from the Subversion and TFS world and I am relatively new to Git. But I can go to a **Staged** file and click on the menu `Git > Compare with unmodified` where I will see the Visual Studio compare tool doing its job. If there is a way to do this on staged files, I presume there also must be a way to mark the track changes on the margin of the text editor for staged files. – sergiol Mar 25 '23 at 18:00