Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "git checkout" do if no argument is provided?

Tags:

git

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

like image 790
Vaibhav Gupta Avatar asked Mar 09 '18 11:03

Vaibhav Gupta


People also ask

What does git pull without arguments do?

Without any arguments, git merge will merge the corresponding remote tracking branch to the local working branch.

What does git checkout actually do?

The git checkout command lets you navigate between the branches created by git branch . Checking out a branch updates the files in the working directory to match the version stored in that branch, and it tells Git to record all new commits on that branch.

Does git checkout automatically pull?

More info: autosetupmerge defaults to true . When set to true, this lets git to perform tracking when you checkout an already existing branch at the remote. For example, if you do git checkout <branch> , git will handle the tracking info so that you can do git pull while on that branch.

What happens when you checkout a commit?

Checking out a commit hash will put you into "detached head" state. A commit (hash) can belong to many branches, and many branch HEADs can point to the same commit hash. Checking out a commit (regardless if it is the HEAD of any branch) will put you to the detached HEAD state.


2 Answers

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

like image 84
Useless Avatar answered Oct 12 '22 11:10

Useless


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

like image 24
David Avatar answered Oct 12 '22 10:10

David