Reputation: 7504
Is there any way or neat documentation where I could see what are all the steps or stages when we run a git command.
For example, when we do a git pull. I believe
But that's something I devised from logs. Is there any way I could actually see what is run as part of a git command e.g. git stash -p
. I tried to search for a documentation etc but didn't find anything.
Please help!
Upvotes: 0
Views: 104
Reputation: 45679
Just to offer another perspective...
The fact that one familiar command - git pull
- can be described in terms of two other familiar commands - git fetch
and git merge
, roughly and by default at least - is something of an anomaly.
Most users only learn a somewhat small subset of git commands, known as "porcelain" commands. There are many more commands that implement more basic operations within git - the "plumbing commands". Many of the porcelain commands build up their functionality from plumbing commands. Maybe you know those plumbing commands, or maybe not; by design, you could use git for your source control without knowing they even exist.
The point being, only a few end-user-facing commands are really just shorthands for other end-user-facing commands. You can use techniques like examining the source or tracing command runs - as others have suggested - to see how a git command might flow. But it's possible you'll see mostly "noise" - commands being built in terms of things that are unfamiliar anyway.
(Another limitation of using trace logging is, you only trace the instances of the commands you run. For example, you've seen that pull
is like fetch and merge
, but this doesn't point out to you that under a different configuration it's more like fetch and rebase
.)
So I would contend that in the majority of cases, the most useful way to build more understanding of a git command, whether or not that understanding is in terms of "equivalence to other commands", is to refer to the docs for the command you want to understand.
That said, you mention stash
and it's a bit of an exception if you really want to understand what it does, because the docs seem to figure it's all implementation details that you don't need. It's somewhat understandable; knowing that a stash is a collection of commits and a reflog entry set up in a particular way may satisfy curiosity, but for most users it's not very practical knowledge and only presents opportunities to shoot oneself in the foot.
Upvotes: 0
Reputation: 488491
The only truly reliable way is to consult the source code. Be aware, though, that the source to Git evolves: git pull
was once a shell script, but now it is a C program.
You can, however, set the environment variable GIT_TRACE
, which Git uses to know to print messages as it runs various sub-commands.
Upvotes: 1
Reputation: 205
I believe what you need are those commands:
GIT_TRACE=1 git fetch origin master
GIT_TRACE=1 git pull origin master
git have plenty of different debug tags. You can find them here:
https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables#Debugging
Upvotes: 2