Does git "fetch" automatically or only when I speak?

I am using git in bash and I have one of these fancy bash prompts that gives me some information in a repository without typing in git status

. It tells me which branch I am on, how many modified and unchecked files and, as far as this is concerned, how far ahead / behind the remote.

I recently started to notice something strange: often when I hit the enter button and a new prompt appears, it suddenly tells me that I am multiple commits behind the master. And, in fact, I, the "git status" confirms this. But my question is, how does he know? By no means did I run git fetch

or git pull

or any other command that would speak to the remote and figure out how far / beyond my local check. In fact, I've seen this happen where I'm pretty sure I haven't run any git commands in between, other than those git status -z --porcelain

that run when the bash script is prompted to generate the request.

It beat me up a bit. I mean the information is certainly helpful, but the idea of ​​something executing git commands in my repository without knowing it is a little unsettling. So here are my questions:

  • Does git do it like this? Perform selections automatically in the background as a result of running some other command? Obviously, the push / pull, you must run the sample to run, but I'm talking about "local" type commands git status

    , git add

    , git commit

    , git diff

    , etc.

  • Is there some kind of "command log" in git where I can check what operations were performed, when and by whom?

+3


source to share


3 answers


  • No that's not
  • Not that I know. You can set an environment variable GIT_TRACE

    , then Git will tell you what commands it calls internally.


+1


source


I am using git in bash, and I have one of these fancy bash prompts that gives me some information in the repository without having to type git status.



This seems like the most likely culprit, by far. Magicmonty is one example of a git script prompt that works git fetch

(see gitprompt.sh

). I bet you find the culprit if you look at the script that asks your prompt.

+1


source


Unless you (or someone else) created something special on your computer to make it run selections, you are not. Forward / backward counting is a comparison of your local branch with a remote link updated with the most recent connection to the server.

So how do you explain this? Since this is probably related to something of interest to your setup, I can imagine speculation at best.

Of course I work in multiple windows, so sometimes my tooltip in one is out of date because I was working in another and pressing ENTER updates it. Of course, you probably know if you are doing this ... but a similar case (it should never be, but I cannot rule out from my knowledge of your system) is if your local repo is in a shared repository and another user is running too with it, you can see the results of your work. (If so, I highly recommend that every developer work on a great repo that is accessed only by the one accessed by one developer for exactly what the clones are for. But as I said, this is all just inference. ..)

Another obvious possibility might be that if someone thought it would be helpful to have the fetch run on schedule in the background. I find it aggravating personally, but I can imagine this happening and it explains the behavior you are seeing.

0


source







All Articles