问题
Sometimes a git checkout
command gives progress feedback:
$ git checkout develop
Checking out files: 100% (10779/10779), done.
Switched to branch 'develop'
Sometimes it doesn't, (very next command line, same repo context):
$ git checkout master
Switched to branch 'master'
It's not because the branches are equal, because switching back on the very next command shows this feedback:
$ git checkout develop
Checking out files: 47% (5067/10779), done.
Switched to branch 'develop'
This happens for small repos also. I have a repo with just 13 files in it and when I add a file in a branch and use checkout to switch back and forth, I get no feedback either way. Is it some kind of "this is taking a long time, start showing feedback" timer?
I searched (Google, Stackoverflow) but didn't find anything specific. I did find some patch documentation that shows the addition of a --verbose flag to checkout that forces feedback to always happen, but I couldn't find an explanation for why feedback only happens sometimes without that patch. The same notes pointed out that feedback only happens if isatty() returns true, but that's not relevant here, since all of the commands above were typed into the same bash window, which presumably isatty.
I'm using git version 1.8.1.msysgit.1
(downloaded from git-scm.com as 1.8.1.3), which does not have the --verbose patch as far as I can tell.
回答1:
This checkout output should now be more consistent with Git 2.7 (Nov./Dec. 2015)
See commit 870ebdb (01 Nov 2015) by Edmundo Carmona Antoranz (eantoranz).
(Merged by Junio C Hamano -- gitster -- in commit 6a38bd6, 05 Nov 2015)
"
git checkout
" did not follow the usual "--[no-]progress
" convention and implemented only "--quiet
" that is essentially a superset of "--no-progress
".
Extend the command to support the usual "--[no-]progress
".
The git checkout doc now shows:
--[no-]progress::
Progress status is reported on the standard error stream by default when it is attached to a terminal, unless
--quiet
is specified.
This flag enables progress reporting even if not attached to a terminal, regardless of--quiet
.
checkout
: add--progress
optionUnder normal circumstances, and like other git commands,
git checkout
will write progress info to stderr if attached to a terminal.
This option allows progress to be forced even if not using a terminal.
Also, progress can be skipped if using option--no-progress
.
回答2:
Under normal conditions, you will see output when checking out if the operation's been running for more than one second.
来源:https://stackoverflow.com/questions/15234357/what-controls-git-checkout-feedback