Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run git push/pull commands with SSH verbose mode?

Tags:

git

ssh

If I run "git push" with the GIT_TRACE=2 environment variable, I get the following:

09:25:28.098743 git.c:349               trace: built-in: git 'push' 'origin' 'master' 09:25:28.100261 run-command.c:341       trace: run_command: 'ssh' '[email protected]' 'git-receive-pack '\''kevinburke/letter.git'\''' 

Which is great except sometimes I get this error:

fatal: Could not read from remote repository. 

I only get it intermittently so I'm not sure what's going on. I know ssh has a verbose mode:

 -v      Verbose mode. Causes ssh to print debugging messages about its progress.           This is helpful in debugging connection, authentication, and configuration          problems.  Multiple -v options increase the verbosity.  The maximum is 3. 

It would be great if I could get git to run that ssh command with -vvv turned on. Is there a way to enable this with environment variables or with config settings?

like image 410
Kevin Burke Avatar asked Aug 19 '14 16:08

Kevin Burke


People also ask

How do I run ssh in verbose mode?

The ssh client's -v switch allows you to run ssh in verbose mode, that prints debugging information about SSH connection progress, which is really useful for debugging connections, authentication, and any configuration problems.

What is git verbose?

Today I want to talk about a little-know flag for the git commit command that I think will help you create better commits: -v , also known as --verbose . Use this flag and Git will include the diff of the changes at the bottom of the commit message template: I think this is helpful for a couple of reasons.

What is Git_ssh_command?

Finally, GIT_SSH_COMMAND means Git 2.10+, so if your version of Git is too old, you will need to update it first. Follow this answer to receive notifications.


1 Answers

From Git version 2.3.0, you can use the environment variable GIT_SSH_COMMAND and pass the -v verbose argument like this:

GIT_SSH_COMMAND="ssh -v" git clone <REPO_SSH> 

you can also pass -vvv for even more verbose level:

GIT_SSH_COMMAND="ssh -vvv" git clone <REPO_SSH> 

(as seen here https://askubuntu.com/a/620985/975188)

note that you can also run this with other git commands, such as git push, git fetch etc.

From Git version 2.10.0, you can even configure this per repo or globally:

git config core.sshCommand "ssh -v" git pull git push 
like image 121
Flimm Avatar answered Sep 20 '22 20:09

Flimm