I am using VsCode and the gutter features (the blue, red, and green highlighted sections on the side) which show file modifications are extremely useful. However, after a commit, those gutters go away.
I would still like to see the gutter modifications compared to what's on origin/master. I know that using the gitlens extension you can use the "open changes with" command and select a branch to compare with. But that opens a new dialog with the two files side by side. What I'm looking for is a way to keep the gutters to show all my changes. That way the areas which I've changed are visible at a glance.
I accomplish this same workflow by doing a git reset to origin/master, and then resetting back to the previous commit before I make any other commits.
For example, if I am on a branch which is some commits ahead of origin/master, and want VSCode to show differences since origin/master, I would do:
git reset origin/master
This does not modify the content of any files, but it does move HEAD so that VSCode and other editors show the differences between origin/master and the current branch. Be careful not to make any git checkouts or commits while in this state, or you will have to use reflog to get back to the commits ahead of origin/master.
Then to return to the state with all of the commits ahead of master, do:
git reset HEAD@{1}
This will move HEAD back to where it was before the first reset, and all of the file changes you have made since then will remain intact. At this point, git diff and VSCode will show the changes you have made since your last commit. You can make a commit in this state and it will contain only the changes you have made since that previous commit (i.e. not all of them since origin/master).
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