Reputation: 145
I know I can install the GitLens extension and view the Git Blame & Git History when the file is open. What I would like to know is how to set this automatically in my .gitconfig file.
I'm expecting the behaviour to be similar to git gui blame & gitk where it launches VSCode and instantly I can see the blame annotations or history panel.
Here is how my .gitconfig file looks like now:
[credential]
helper = store
[user]
email = [email protected]
name = MyName
[core]
editor = code --wait
[diff]
tool = vscode
[difftool "vscode"]
cmd = code --wait --diff $LOCAL $REMOTE
[merge]
tool = vscode
[mergetool "vscode"]
cmd = code --wait $MERGED
[cola]
spellcheck = false
expandtab = true
blameviewer = code --wait **What should this line be?**
[gui]
editor = code
historybrowser = code --wait **What should this line be?**
Upvotes: 4
Views: 3150
Reputation: 28623
open the file in VSC and click the git icon in the editor title menu.
Upvotes: 1
Reputation: 7879
The git blame
and git log
commands pipe their output to a pager instead of an editor, so you have to set the core.pager
setting in your git config.
Try this:
git config --global core.pager 'code --wait'
Then run git blame <file>
and it will open VSCode.
I don't have VSCode to test this, but this likely just opens the normal output of git blame
in VSCode. VSCode probably won't automatically reformat the output and put the annotations in the gutter of the IDE window. It will look the same as running the command on the CLI with the default pager.
Upvotes: 2