我知道我可以安装GitLens扩展并查看Git Blame&打开文件时的Git历史记录。我想知道的是如何在我的.gitconfig文件中自动设置它。
我希望这种行为类似于gitgui指责&gitk,它在那里启动VSCode,我可以立即看到指责注释或历史面板。
下面是我的.gitconfig文件现在的样子:
[credential]
helper = store
[user]
email = MyEmail@hotmail.com
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?**
git blame
和git log
命令通过管道将其输出发送到寻呼机而不是编辑器,因此必须在git配置中设置core.pager
设置。
试试这个:
git config --global core.pager 'code --wait'
然后运行git blame <file>
,它将打开VSCode。
我没有VSCode来测试这一点,但这可能只是打开了VSCode中git blame
的正常输出。VSCode可能不会自动重新格式化输出并将注释放在IDE窗口的槽中。它看起来与使用默认寻呼机在CLI上运行命令相同。
在VSC中打开文件,然后单击编辑器标题菜单中的git图标。