How can I debug git / git-shell problems?

How can I get debug information about git / git-shell?

I had a problem that user1 can clone a repository without problems, and user2 can clone only empty. I set GIT_TRACE=1 , but nothing useful was said.

Finally, after a long trial and error, it turned out that this is a file permission problem. A corresponding error message may cause a short circuit of this problem.

+126
git debugging tracing trace
May 30 '11 at 15:58
source share
8 answers

For more detailed output, use the following:

GIT_CURL_VERBOSE=1 GIT_TRACE=1 git pull origin master

+181
Jun 27 '13 at 13:28
source share

debugging

Git has a fairly complete set of traces that you can use to debug your problems with git.

To enable them, you can define the following variables:

  • GIT_TRACE for shared traces,
  • GIT_TRACE_PACK_ACCESS to track access to the batch file,
  • GIT_TRACE_PACKET for packet level tracing for network operations,
  • GIT_TRACE_PERFORMANCE for recording performance data,
  • GIT_TRACE_SETUP to obtain information about the discovery of the storage and the environment with which it interacts,
  • GIT_MERGE_VERBOSITY for debugging a recursive merge strategy (values: 0-5),
  • GIT_CURL_VERBOSE to log all curl messages (equivalent to curl -v ),
  • GIT_TRACE_SHALLOW for debugging the extraction / cloning of small repositories.

Possible values ​​may include:

  • true , 1 or 2 to write to stderr,
  • absolute path starting with / to trace output to the specified file.

For more information see: Git Internals - Environment Variables




Ssh

For SSH problems, try the following commands:

 echo 'ssh -vvv "$*"' > ssh && chmod +x ssh GIT_SSH="$PWD/ssh" git pull origin master 

or use ssh to verify your credentials e.g.

 ssh -vvvT git@github.com 

or through the HTTPS port:

 ssh -vvvT -p 443 git@ssh.github.com 

Note. Decrease -v to decrease -v .




Examples

 $ GIT_TRACE=1 git status 20:11:39.565701 git.c:350 trace: built-in: git 'status' $ GIT_TRACE_PERFORMANCE=$PWD/gc.log git gc Counting objects: 143760, done. ... $ head gc.log 20:12:37.214410 trace.c:420 performance: 0.090286000 s: git command: 'git' 'pack-refs' '--all' '--prune' 20:12:37.378101 trace.c:420 performance: 0.156971000 s: git command: 'git' 'reflog' 'expire' '--all' ... $ GIT_TRACE_PACKET=true git pull origin master 20:16:53.062183 pkt-line.c:80 packet: fetch< 93eb028c6b2f8b1d694d1173a4ddf32b48e371ce HEAD\0multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag multi_ack_detailed symref=HEAD:refs/heads/master agent=git/2:2.6.5~update-ref-initial-update-1494-g76b680d ... 
+66
Aug 01 '16 at 19:17
source share

try the following:

 GIT_TRACE=1 git pull origin master 
+42
Dec 10
source share

If its more than SSH, you can use the following:

For a higher debugging level for type -vv or -vvv for debugging level 2 and 3, respectively:

 # Debug level 1 GIT_SSH_COMMAND="ssh -v" git clone <repositoryurl> # Debug level 2 GIT_SSH_COMMAND="ssh -vv" git clone <repositoryurl> # Debug level 3 GIT_SSH_COMMAND="ssh -vvv" git clone <repositoryurl> 

This is mainly useful for solving problems with public and private keys with the server. You can use this command for any git command, not just git clone '.

+36
Jan 26 '16 at 15:17
source share

Git 2.9.x / 2.10 (Q3 2016) adds another debugging option: GIT_TRACE_CURL .

See Commit 73e57aa , commit 74c682d (May 23, 2016) Elia Pinto ( devzero2000 ) .
Assistant: Thorsten Begershausen ( tboegi ) , Ramsey Jones, Junior S Hamano ( gitster ) , Eric Sunshine ( sunshineco ) and Jeff King ( peff ) .
(Merger with Junio ​​C Hamano - gitster - completed by 2f84df2 , July 6, 2016)

http.c : implement the GIT_TRACE_CURL environment GIT_TRACE_CURL

GIT_TRACE_CURL environment GIT_TRACE_CURL to provide a greater granularity of GIT_CURL_VERBOSE , in particular the full transport header and all data payload.
This can be useful if a more detailed debug analysis is required in a particular situation.

The documentation will indicate:

 GIT_TRACE_CURL 

Allows you to twist the full rollback of all incoming and outgoing data, including descriptive information, the git transfer protocol.
This is similar to running curl --trace-ascii on the command line.

This parameter overrides the setting of the GIT_CURL_VERBOSE environment GIT_CURL_VERBOSE .




You can see this new option used in this answer , but also in the Git 2.11 tests (Q4 2016):

See Commit 14e2411 , commit 81590bf , commit 4527aa1 , commit 4eee6c6 (07 Sep 2016) from Elia Pinto ( devzero2000 ) .
(Merger with Junio ​​S Hamano - gitster - on 930b67e , 12 Sep 2016)

Use the new GIT_TRACE_CURL environment GIT_TRACE_CURL instead of the obsolete GIT_CURL_VERBOSE .

 GIT_TRACE_CURL=true git clone --quiet $HTTPD_URL/smart/repo.git 
+18
Jul 09 '16 at 20:01
source share

Have you tried adding a verbose ( -v ) operator when cloning?

git clone -v git://git.kernel.org/pub/scm/.../linux-2.6 my2.6

+4
May 30 '11 at 16:03
source share

For older versions of git (1.8 and earlier)

I could not find a suitable way to enable SSH debugging in older versions of git and ssh. I searched for environment variables using ltrace -e getenv ... and could not find any combination of GIT_TRACE or SSH_DEBUG variables that would work.

Instead, there is a recipe for temporarily injecting 'ssh -v' into the git-> ssh sequence:

 $ echo '/usr/bin/ssh -v ${@}' >/tmp/ssh $ chmod +x /tmp/ssh $ PATH=/tmp:${PATH} git clone ... $ rm -f /tmp/ssh 

Here is the output from git version 1.8.3 with ssh version OpenSSH_5.3p1, OpenSSL 1.0.1e-fips February 11, 2013 cloning the github repository:

 $ (echo '/usr/bin/ssh -v ${@}' >/tmp/ssh; chmod +x /tmp/ssh; PATH=/tmp:${PATH} \ GIT_TRACE=1 git clone https://github.com/qneill/cliff.git; \ rm -f /tmp/ssh) 2>&1 | tee log trace: built-in: git 'clone' 'https://github.com/qneill/cliff.git' trace: run_command: 'git-remote-https' 'origin' 'https://github.com/qneill/cliff.git' Cloning into 'cliff'... OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013 debug1: Reading configuration data /home/q.neill/.ssh/config debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug1: Connecting to github.com ... ... Transferred: sent 4120, received 724232 bytes, in 0.2 seconds Bytes per second: sent 21590.6, received 3795287.2 debug1: Exit status 0 trace: run_command: 'rev-list' '--objects' '--stdin' '--not' '--all' trace: exec: 'git' 'rev-list' '--objects' '--stdin' '--not' '--all' trace: built-in: git 'rev-list' '--objects' '--stdin' '--not' '--all' 
+2
Aug 15 '19 at 23:14
source share

Git 2.22 (Q2 2019) introduces trace2 with commit ee4512e by Jeff Hostetler :

trace2 : create a new combined tracer

Create a new unified tracer for git.
A possible intention is to replace the current routines trace_printf* and trace_performance* unified set of routines git_trace2* .

In addition to the regular printf-style API, trace2 provides a higher level event verb with fixed fields that allow you to write structured data.
This facilitates post-processing and analysis for external tools.

Trace2 defines 3 output targets.
They are set using the environment variables " GIT_TR2 ", " GIT_TR2_PERF " and " GIT_TR2_EVENT ".
They can be set to "1" or an absolute path (exactly the same as the current GIT_TRACE ).

Note: for the environment variable name, always use GIT_TRACExxx , not GIT_TRxxx .
So actually GIT_TRACE2 , GIT_TRACE2_PERF or GIT_TRACE2_EVENT .
See the renaming of Git 2.22, mentioned below.

The following is the initial work on this new trace function with the old environment variable names:

  • GIT_TR2 intended to replace the GIT_TRACE and the logs summary data.

  • GIT_TR2_PERF intended to replace GIT_TRACE_PERFORMANCE .
    It expands the output columns for the team process, flow, repo, absolute and relative elapsed time. It reports events for starting / stopping a child process, starting / stopping a thread, and a function for each nesting thread.

  • GIT_TR2_EVENT is a new structured format. It records event data as a series of JSON records.

Trace2 function calls are logged into any of the 3 included output targets without the need to call the various routines trace_printf* or trace_performance* .

See commit a4d3a28 (March 21, 2019) by Josh Steadmon ( steadmon ) . (Merged by Junio ​​C Hamano - [TG423] - in commit 1b40314 , 08 May 2019)
trace2 : write to target directory

If the value of the environment variable trace2 is an absolute path that refers to an existing directory, write the output to files (one per process) under the specified directory.

Files will be named according to the last SID trace2 component followed by a counter to avoid potential conflicts.
This makes it more convenient to collect traces for each git call, unconditionally setting the corresponding trace2 envvar constant directory name.

see also




commit f672dee (April 29, 2019) and commit 81567ca , commit 08881b9 , commit bad229a , commit 26c6f25 , commit bce9db6 , commit 800a7f9 , commit a7bc01e , commit 39f4317 , commit a089724 , commit 1703751 (April 15, 2019) Jeffrey jeffhostetler . (Merged by Junio ​​C Hamano - [TG427] - in commit 5b2d1c0 , 13 May 2019)
new documentation

now includes configuration parameters that are read only from the system and global configuration files (which means that local configuration files and working tree configuration files and -c command line arguments are not taken into account). An example :

 $ git config --global trace2.normalTarget ~/log.normal $ git version git version 2.20.1.155.g426c96fcdb 
gives

 $ cat ~/log.normal 12:28:42.620009 common-main.c:38 version 2.20.1.155.g426c96fcdb 12:28:42.620989 common-main.c:39 start git version 12:28:42.621101 git.c:432 cmd_name version (version) 12:28:42.621215 git.c:662 exit elapsed:0.001227 code:0 12:28:42.621250 trace2/tr2_tgt_normal.c:124 atexit elapsed:0.001265 code:0 

And for

performance indicator

:

 $ git config --global trace2.perfTarget ~/log.perf $ git version git version 2.20.1.155.g426c96fcdb 
gives

 $ cat ~/log.perf 12:28:42.620675 common-main.c:38 | d0 | main | version | | | | | 2.20.1.155.g426c96fcdb 12:28:42.621001 common-main.c:39 | d0 | main | start | | 0.001173 | | | git version 12:28:42.621111 git.c:432 | d0 | main | cmd_name | | | | | version (version) 12:28:42.621225 git.c:662 | d0 | main | exit | | 0.001227 | | | code:0 12:28:42.621259 trace2/tr2_tgt_perf.c:211 | d0 | main | atexit | | 0.001265 | | | code:0 

As described in Git 2.23 (Q3 2019), the environment variable used is

GIT_TRACE2


. See commit 6114a40

(June 26, 2019) by Carlo Marcelo Arenas Belon ( carenas ) . See commit 3efa1c6
(June 12, 2019), author Γ†war Arnfjord Bjarmason ( avar ) . (Merged by Junio ​​C Hamano - [TG436] - in commit e9eaaa4 , 09 Jul 2019) This follows the work done in Git 2.22:
commit 4e0d3aa

commit e4b75d6 (May 19, 2019) SZEDER GΓ‘bor ( szeder ) . . (Merged by Junio ​​C Hamano - [TG438] - in commit 463dca6 , 30 May 2019)
trace2 : rename environment variables to GIT_TRACE2 *

For the environment variable that users should set, the GIT_TR2* variables GIT_TR2* simply too obscure, inconsistent, and ugly.

Most of the established GIT_* environment variables don't use abbreviations, and in case of the few that do ( GIT_DIR , GIT_COMMON_DIR , GIT_DIFF_OPTS ) it quite obvious what the abbreviations ( DIR and OPTS ) stand for.
But what does TR stand for? Track, traditional, trailer, transaction, transfer, transformation, transition, translation, transplant, transport, traversal, tree, trigger, truncate, trust, or ...?!

The trace2 tool, as the suffix name "2" implies, should eventually replace the original Git trace.

It is reasonable to expect the corresponding environment variables to follow suit, and after the original GIT_TRACE variables they are called GIT_TRACE2 ; there is no such thing as " GIT_TR ".
All trace2-specific configuration variables are very reasonable Section " trace2 ", not " tr2 ".

General relativity

we get nothing by omitting the last three β€œtrace” characters from the names of these environment variables . So, let's rename all the GIT_TR2* environment variables to GIT_TRACE2* before they get to the stable release.

Git 2.24 (Q3 2019) improves the initialization of the Git repository.




Cm.

commit 22932d9 , commit 5732f2b , commit 58ebccb (August 6, 2019) by Jeff King ( peff ) . .
(Merged by Junio ​​C Hamano - [TG456] - in commit b4a1eec , 09 Sep 2019)

common-main: trace2 initialization delay

We initialize the trace2 system in the general function main () so that all programs (even those that are not built-in) will include tracing.

But running trace2 relatively difficult, since we have to read the configuration on disk to decide whether to track.
This can cause unexpected interactions with other common core initializations. For example, we will prove the configuration code before calling initialize_the_repository() , and the usual invariant, which the_repository will never be NULL, will not be held.

Let's push the initialization of trace2 further down in general, so that shortly before we execute cmd_main() .

+1
May 11 '19 at 22:20
source share



All Articles