Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does 'track' mean when creating a new branch in git?

Tags:

git

aptana

I'm using Aptana and Git. When I go to create a new branch, the following dialog box shows up.

enter image description here

I was wondering what that 'track' checkbox does, and when it's most appropriate to check it.

I understand the concept of tracking in git, but mostly with files. I don't seem to understand how it applies to new branches being created?

like image 945
Sajan Parikh Avatar asked Feb 03 '13 19:02

Sajan Parikh


People also ask

What does it mean to track a branch git?

Tracking branches are local branches that have a direct relationship to a remote branch. If you're on a tracking branch and type git pull , Git automatically knows which server to fetch from and which branch to merge in.

What does track branch mean?

Here's the definition from git-scm.com: 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.

How do I create a new branch in git?

New Branches 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.

How do you set a remote to track a branch?

When you're publishing a local branch. You can tell Git to track the newly created remote branch simply by using the -u flag with "git push".


1 Answers

In this case, track refers to git-checkout's and git-branch's --track option.

When a local branch is started off a remote-tracking branch, git sets up the branch so that git pull will appropriately merge from the remote-tracking branch.

From man git-branch:

-t, --track
    When creating a new branch, set up configuration to mark the
    start-point branch as "upstream" from the new branch. This
    configuration will tell git to show the relationship between the
    two branches in git status and git branch -v. Furthermore, it
    directs git pull without arguments to pull from the upstream when
    the new branch is checked out.
like image 140
Marco Leogrande Avatar answered Sep 21 '22 20:09

Marco Leogrande