Visual Studio Team Explorer - View Git Commands
Asked Answered
D

3

14

New versions of Visual Studio Team Explorer has built in support for Git.

I want to know if there is an option to view the Git commands executed while using the Team explorer for Git actions like Commit and Push.

Also would be better to have an option to view the other commands executed by Team Explorer like fetching status.

Are those features available with the current Visual Studio?

Dom answered 31/7, 2016 at 7:0 Comment(1)
Still true as of Oct 2020: on my windows 10 machine with VS 2019 - I popped out of Visual Studio to run a custom git command, namely git reset --hard origin/develop, and was shocked that no Git was installed on my workstationRicard
G
6

Git has a number of traces embedded which you can turn on by use git's tracing environment variables. To enable basic general logging:

  1. Open Command Prompt
  2. Run setx GIT_TRACE %UserProfile%\git.log
  3. Restart Visual Studio and Execute the git commands.
  4. Examine the git.log file

To disable logging:

  1. Open Command Prompt
  2. Run setx GIT_TRACE ""
  3. Restart Visual Studio.

Should you want to do other types of git tracing, you can also turn on other traces at the command line and point them at the same log file:
Run setx GIT_TRACE_CURL %UserProfile%\git.log
Run setx GCM_TRACE %UserProfile%\git.log
etc

See more environment variable examples at:
Git Internals - Environment Variables
and
How can I debug git/git-shell related problems?

Gilud answered 22/5, 2019 at 17:15 Comment(1)
Two thoughts about this: 1. The log shows up in the root "Users" folder. Need to specify user name in step 2 if you want it in your own folder. 2. The results were disappointing. I did an undo for one file in team explorer and the log file showed 68 lines for this activity. None of the lines were obvious as to which one actually did the undo.Contend
J
3

Edit: VisualStudio no more use libgit2sharp but use pure git commands but that changes nothing to the fact that you can't see the commands run.

No, there is no option to do that. And that seems quite impossible because Visual Studio don't run git commands but use the library libgit2sharp to manage the git repositories.

If you use the git GUI 'GitExtensions', there is a possibility to see all the git commands run (but unfortunately, that is difficult to understand because the GUI run a lot of commands).

Joke answered 31/7, 2016 at 8:6 Comment(1)
I was also expecting this as I have read that VS doesn't use GIT commands directly but a git library.Dom
M
1

The official Visual Studio Git tutorial does not mention that feature at all.

As this uservoice suggestion suggests, going to command-line and repeating the command (when the one done by Visual Studio failed) is the current method to know more about what is going on.

You can see the Git command in the Terminal / Output / Git.

Monies answered 31/7, 2016 at 7:20 Comment(2)
The link to the uservoice suggestion is broken. Can you tell me, how ot repeat the command when I cannot see it?Thurman
@Thurman Try and "Focus on Terminal View", click on Output, then select "Git" in the dropdown list. You will see any Git command done by VSCode.Monies

© 2022 - 2024 — McMap. All rights reserved.