Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"git branch --track" vs "git checkout --track"

What is the difference between "git branch --track" and "git checkout -b --track", if there is any?

like image 334
j-pb Avatar asked Oct 17 '10 11:10

j-pb


People also ask

Is git checkout the same as git branch?

Git checkout works hand-in-hand with git branch . The git branch command can be used to create a new branch. When you want to start a new feature, you create a new branch off main using git branch new_branch . Once created you can then use git checkout new_branch to switch to that branch.

What does git checkout track do?

Git Checkout Remote Branch Definition Git is a way for software developers to track different modifications of their code. It keeps all the various versions in a unique database. Git allows multiple developers to work on the same code simultaneously.

What is git branch -- track?

A 'tracking branch' in Git is a local branch that is connected to a remote branch. When you push and pull on that branch, it automatically pushes and pulls to the remote branch that it is connected with.

What is difference between git checkout and clone?

git clone is to fetch your repositories from the remote git server. git checkout is to checkout your desired status of your repository (like branches or particular files). E.g., you are currently on master branch and you want to switch into develop branch.


2 Answers

Internally git-branch is called and then the new branch is checked out. From the docs.

If -b is given, a new branch is created as if git-branch were called and then checked out; in this case you can use the --track or --no-track options, which will be passed to git branch. As a convenience, --track without -b implies branch creation; see the description of --track below.

like image 81
Jungle Hunter Avatar answered Oct 13 '22 00:10

Jungle Hunter


If I'm not mistaken, git checkout ... will actually create the branch AND switch your working copy to that branch, while git branch ... will just create the branch and leave your working copy alone.

like image 43
theunraveler Avatar answered Oct 13 '22 01:10

theunraveler