Branch
and Checkout do the same thing but there is a small difference between the two.
This post explains the difference between the operation of the branch and checkout commands in Git.
Checkout can be used to create a new branch and traverses to the new branch, any further changes done will be done in the new branch created.
Checkout can also be used to switch to an existing branch, in this case no new branch is created but the [head] traverses to the selected branch. Once the [head] traverses to the new branch, the code/files in the local working copy are updated with the latest version of the files in the selected branch.
Branch, just creates a new branch, but does not traverse to the new branch; any further changes done get reflected in the current (original) branch and not in the new branch created.
Command Line:
git checkout creates a new branch and switches to the new
branch
git branch creates a new branch but does not switch to the
new branch, will have to use the checkout command to switch to the new Branch.
Checkout can be used to create a new branch and traverses to the new branch, any further changes done will be done in the new branch created.
Checkout can also be used to switch to an existing branch, in this case no new branch is created but the [head] traverses to the selected branch. Once the [head] traverses to the new branch, the code/files in the local working copy are updated with the latest version of the files in the selected branch.
Branch, just creates a new branch, but does not traverse to the new branch; any further changes done get reflected in the current (original) branch and not in the new branch created.
Command Line:
git checkout
git branch
No comments:
Post a Comment