23

I accidentally typed git checkout in GIT CMD without any arguments in my working branch. The parent branch name is development. After I hit the command it showed the following:

M       analytics-engine/build.gradle
M       analytics-engine/src/main/groovy/com/oracle/emcsas/securityanalytics/stats/timebucket/ExternalizeTimeBucket.java
M       analytics-engine/src/main/groovy/com/oracle/emcsas/securityanalytics/stats/timebucket/TimeBucket.java

But I did not notice any changes in my local branch. All the changes are there. So what did it actually do.

git version 2.15.0.windows.1

Vaibhav Gupta
  • 351
  • 2
  • 8
  • A different but related question is this: What did you *want* it to do? Why did you execute it? Only to learn git? Or did you execute it in the hopes that it did something specific? – Lasse V. Karlsen Mar 09 '18 at 11:38
  • 1
    Have you read the [documentation of `git checkout`](https://git-scm.com/docs/git-checkout)? It is explained there: *"You could omit , in which case the command degenerates to "check out the current branch", which is a glorified no-op with rather expensive side-effects to show only the tracking information, if exists, for the current branch."* – axiac Mar 09 '18 at 11:39
  • Possible duplicate of [What do git checkouts really mean?](https://stackoverflow.com/questions/15296473/what-do-git-checkouts-really-mean) – Xavier Guihot Mar 09 '18 at 11:52

2 Answers2

19

The documentation says

git checkout <branch>

...

You could omit <branch>, in which case the command degenerates to "check out the current branch", which is a glorified no-op with rather expensive side-effects to show only the tracking information, if exists, for the current branch

Community
  • 1
  • 1
Useless
  • 64,155
  • 6
  • 88
  • 132
13

It shows you the current modified and not commited files in your current branch

David
  • 614
  • 5
  • 20
  • If there is a tracking branch it equals `git checkout -b --track /` – evolutionxbox Mar 09 '18 at 11:37
  • @evolutionxbox - No, it doesn't, as is obvious if you try to explain what `` is in your supposedly-equivalent command, while remembering that the question is what happens when you don't supply a branch name. – Mark Adelsberger Mar 09 '18 at 14:26
  • @MarkAdelsberger I'm getting this information from the git docs. https://git-scm.com/docs/git-checkout#git-checkout-emgitcheckoutemltbranchgt - _"If is not found but there does exist a tracking branch in exactly one remote (call it ) with a matching name, treat as equivalent to [...]"_ – evolutionxbox Mar 09 '18 at 14:28
  • @evolutionxbox - Ok. So in your estimation, what is `` set to in the equivalent command, if I say `git checkout` with no further arguments? – Mark Adelsberger Mar 09 '18 at 14:37
  • Hmmm. Good point, I think I've read that part of the docs and assuming it's used when branch isn't there. It's not, only if the remote exists. – evolutionxbox Mar 09 '18 at 14:44
  • I also noticed that. It just summarizes the changes in your working dir (modified files are marked with 'M', deleted files with 'D', untracked files are not mentioned). But I couldnt any reference to this behavior in documentation. – AgostinoX Jan 20 '22 at 00:06