我怎么能有一些关于git/git-shell的调试信息?
我遇到了一个问题,user1可以毫无问题地克隆一个存储库,而user2只能克隆一个空的存储库。我设置了GIT_TRACE=1,但是没有任何有用的提示。
最后,经过长时间的尝试和错误,发现这是一个文件的权限问题。适当的错误消息可以避免此问题。
我怎么能有一些关于git/git-shell的调试信息?
我遇到了一个问题,user1可以毫无问题地克隆一个存储库,而user2只能克隆一个空的存储库。我设置了GIT_TRACE=1,但是没有任何有用的提示。
最后,经过长时间的尝试和错误,发现这是一个文件的权限问题。适当的错误消息可以避免此问题。
当前回答
Git 2.39 (Q4 2022)增加了两个新的跟踪功能,“计时器”和“计数器”:
参见Jeff Hostetler (Jeff-Hostetler)的commit 8107162, commit 8ad5756, commit 24a4c45, commit 3124793, commit a70839c, commit 8e8c5ad, commit 5bbb925, commit 545ddca(2022年10月24日)。 (由Taylor Blau—Taylor—在commit e5be3c6中合并,2022年10月30日)
Trace2:添加秒表计时器 署名:Jeff Hostetler
Timers are an alternative to Trace2 Regions. Regions are useful for measuring the time spent in various computation phases, such as the time to read the index, time to scan for unstaged files, time to scan for untracked files, and etc. However, regions are not appropriate in all places. For example, during a checkout, it would be very inefficient to use regions to measure the total time spent inflating objects from the ODB (Object DataBase) from across the entire lifetime of the process; a per-unzip() region would flood the output and significantly slow the command; and some form of post-processing would be required to compute the time spent in unzip(). Timers can be used to measure a series of timer intervals and emit a single summary event (at thread and/or process exit).
Technical /api-trace2现在在它的手册页中包括:
"th_timer" This event logs the amount of time that a stopwatch timer was running in the thread. This event is generated when a thread exits for timers that requested per-thread events. { "event":"th_timer", ... "category":"my_category", "name":"my_timer", "intervals":5, # number of time it was started/stopped "t_total":0.052741, # total time in seconds it was running "t_min":0.010061, # shortest interval "t_max":0.011648 # longest interval } "timer" This event logs the amount of time that a stopwatch timer was running aggregated across all threads. This event is generated when the process exits. { "event":"timer", ... "category":"my_category", "name":"my_timer", "intervals":5, # number of time it was started/stopped "t_total":0.052741, # total time in seconds it was running "t_min":0.010061, # shortest interval "t_max":0.011648 # longest interval }
Technical /api-trace2现在在它的手册页中包括:
Stopwatch Timer Events Measure the time spent in a function call or span of code that might be called from many places within the code throughout the life of the process. static void expensive_function(void) { trace2_timer_start(TRACE2_TIMER_ID_TEST1); ... sleep_millisec(1000); // Do something expensive ... trace2_timer_stop(TRACE2_TIMER_ID_TEST1); } static int ut_100timer(int argc, const char **argv) { ... expensive_function(); // Do something else 1... expensive_function(); // Do something else 2... expensive_function(); return 0; } In this example, we measure the total time spent in expensive_function() regardless of when it is called in the overall flow of the program. $ export GIT_TRACE2_PERF_BRIEF=1 $ export GIT_TRACE2_PERF=~/log.perf $ t/helper/test-tool trace2 100timer 3 1000 ... $ cat ~/log.perf d0 | main | version | | | | | ... d0 | main | start | | 0.001453 | | | t/helper/test-tool trace2 100timer 3 1000 d0 | main | cmd_name | | | | | trace2 (trace2) d0 | main | exit | | 3.003667 | | | code:0 d0 | main | timer | | | | test | name:test1 intervals:3 total:3.001686 min:1.000254 max:1.000929 d0 | main | atexit | | 3.003796 | | | code:0
并且,仍然使用Git 2.39:
Trace2:添加全局计数器机制 署名:Jeff Hostetler
Add global counters mechanism to Trace2. The Trace2 counters mechanism adds the ability to create a set of global counter variables and an API to increment them efficiently. Counters can optionally report per-thread usage in addition to the sum across all threads. Counter events are emitted to the Trace2 logs when a thread exits and at process exit. Counters are an alternative to data and data_json events. Counters are useful when you want to measure something across the life of the process, when you don't want per-measurement events for performance reasons, when the data does not fit conveniently within a region, or when your control flow does not easily let you write the final total. For example, you might use this to report the number of calls to unzip() or the number of de-delta steps during a checkout.
Technical /api-trace2现在在它的手册页中包括:
"th_counter" This event logs the value of a counter variable in a thread. This event is generated when a thread exits for counters that requested per-thread events. { "event":"th_counter", ... "category":"my_category", "name":"my_counter", "count":23 } "counter" This event logs the value of a counter variable across all threads. This event is generated when the process exits. The total value reported here is the sum across all threads. { "event":"counter", ... "category":"my_category", "name":"my_counter", "count":23 }
其他回答
要获得更详细的输出,请使用以下方法:
GIT_CURL_VERBOSE=1 GIT_TRACE=1 git拉源主
Git 2.39 (Q4 2022)增加了两个新的跟踪功能,“计时器”和“计数器”:
参见Jeff Hostetler (Jeff-Hostetler)的commit 8107162, commit 8ad5756, commit 24a4c45, commit 3124793, commit a70839c, commit 8e8c5ad, commit 5bbb925, commit 545ddca(2022年10月24日)。 (由Taylor Blau—Taylor—在commit e5be3c6中合并,2022年10月30日)
Trace2:添加秒表计时器 署名:Jeff Hostetler
Timers are an alternative to Trace2 Regions. Regions are useful for measuring the time spent in various computation phases, such as the time to read the index, time to scan for unstaged files, time to scan for untracked files, and etc. However, regions are not appropriate in all places. For example, during a checkout, it would be very inefficient to use regions to measure the total time spent inflating objects from the ODB (Object DataBase) from across the entire lifetime of the process; a per-unzip() region would flood the output and significantly slow the command; and some form of post-processing would be required to compute the time spent in unzip(). Timers can be used to measure a series of timer intervals and emit a single summary event (at thread and/or process exit).
Technical /api-trace2现在在它的手册页中包括:
"th_timer" This event logs the amount of time that a stopwatch timer was running in the thread. This event is generated when a thread exits for timers that requested per-thread events. { "event":"th_timer", ... "category":"my_category", "name":"my_timer", "intervals":5, # number of time it was started/stopped "t_total":0.052741, # total time in seconds it was running "t_min":0.010061, # shortest interval "t_max":0.011648 # longest interval } "timer" This event logs the amount of time that a stopwatch timer was running aggregated across all threads. This event is generated when the process exits. { "event":"timer", ... "category":"my_category", "name":"my_timer", "intervals":5, # number of time it was started/stopped "t_total":0.052741, # total time in seconds it was running "t_min":0.010061, # shortest interval "t_max":0.011648 # longest interval }
Technical /api-trace2现在在它的手册页中包括:
Stopwatch Timer Events Measure the time spent in a function call or span of code that might be called from many places within the code throughout the life of the process. static void expensive_function(void) { trace2_timer_start(TRACE2_TIMER_ID_TEST1); ... sleep_millisec(1000); // Do something expensive ... trace2_timer_stop(TRACE2_TIMER_ID_TEST1); } static int ut_100timer(int argc, const char **argv) { ... expensive_function(); // Do something else 1... expensive_function(); // Do something else 2... expensive_function(); return 0; } In this example, we measure the total time spent in expensive_function() regardless of when it is called in the overall flow of the program. $ export GIT_TRACE2_PERF_BRIEF=1 $ export GIT_TRACE2_PERF=~/log.perf $ t/helper/test-tool trace2 100timer 3 1000 ... $ cat ~/log.perf d0 | main | version | | | | | ... d0 | main | start | | 0.001453 | | | t/helper/test-tool trace2 100timer 3 1000 d0 | main | cmd_name | | | | | trace2 (trace2) d0 | main | exit | | 3.003667 | | | code:0 d0 | main | timer | | | | test | name:test1 intervals:3 total:3.001686 min:1.000254 max:1.000929 d0 | main | atexit | | 3.003796 | | | code:0
并且,仍然使用Git 2.39:
Trace2:添加全局计数器机制 署名:Jeff Hostetler
Add global counters mechanism to Trace2. The Trace2 counters mechanism adds the ability to create a set of global counter variables and an API to increment them efficiently. Counters can optionally report per-thread usage in addition to the sum across all threads. Counter events are emitted to the Trace2 logs when a thread exits and at process exit. Counters are an alternative to data and data_json events. Counters are useful when you want to measure something across the life of the process, when you don't want per-measurement events for performance reasons, when the data does not fit conveniently within a region, or when your control flow does not easily let you write the final total. For example, you might use this to report the number of calls to unzip() or the number of de-delta steps during a checkout.
Technical /api-trace2现在在它的手册页中包括:
"th_counter" This event logs the value of a counter variable in a thread. This event is generated when a thread exits for counters that requested per-thread events. { "event":"th_counter", ... "category":"my_category", "name":"my_counter", "count":23 } "counter" This event logs the value of a counter variable across all threads. This event is generated when the process exits. The total value reported here is the sum across all threads. { "event":"counter", ... "category":"my_category", "name":"my_counter", "count":23 }
试试这个:
GIT_TRACE=1 git pull origin master
调试
Git有一个相当完整的嵌入式跟踪集,您可以使用它来调试Git问题。
要打开它们,你可以定义以下变量:
GIT_TRACE for general traces, GIT_TRACE_PACK_ACCESS for tracing of packfile access, GIT_TRACE_PACKET for packet-level tracing for network operations, GIT_TRACE_PERFORMANCE for logging the performance data, GIT_TRACE_SETUP for information about discovering the repository and environment it’s interacting with, GIT_MERGE_VERBOSITY for debugging recursive merge strategy (values: 0-5), GIT_CURL_VERBOSE for logging all curl messages (equivalent to curl -v), GIT_TRACE_SHALLOW for debugging fetching/cloning of shallow repositories.
可能的值包括:
True, 1或2写入stderr, 以/开头的绝对路径,用于跟踪到指定文件的输出。
更多详细信息,请参见:Git内部-环境变量
SSH
对于SSH问题,请尝试以下命令:
echo 'ssh -vvv "$*"' > ssh && chmod +x ssh
GIT_SSH="$PWD/ssh" git pull origin master
或者使用SSH来验证您的凭证,例如。
ssh -vvvT git@github.com
或HTTPS端口:
ssh -vvvT -p 443 git@ssh.github.com
注意:减少-v的个数以减少冗长级别。
例子
$ 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
...
您是否尝试在克隆时添加详细(-v)操作符?
Git克隆-v Git://git.kernel.org/pub/scm/.../linux-2.6 my2.6