Git checkout

When checkout is executed without any parameters, Git performs the following steps:

  1. Fetches the named paths in the working tree.
  2. Fetches the related objects from the index.
  3. Updates the contents of the working tree with the ones from the index.

However the behavior changes according to the parameters used.

Parameter

Description

-b

This is used to spawn a new branch from the checked out position mentioned with the commit ID.

git checkout –b <your_branch_name> is a short form of git checkout branch followed by git checkout <branch_name>.

This command creates a new reference inside .git/refs/heads/ with that particular commit ID.

--track

This parameter is used to set up the upstream configuration usually while creating a new branch with the –b parameter.

When executed, a separate section is added to the .config file inside the .git directory as follows:

[branch "master"]
        remote = origin
        merge = refs/heads/master

This happens when a command like git checkout --track -b master origin/master is executed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.11.28