Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Git Best Practices Guide

You're reading from   Git Best Practices Guide Master the best practices of Git with the help of real-time scenarios to maximize team efficiency and workflow

Arrow left icon
Product type Paperback
Published in Nov 2014
Publisher
ISBN-13 9781783553730
Length 102 pages
Edition 1st Edition
Tools
Arrow right icon
Author (1):
Arrow left icon
PIDOUX Eric PIDOUX Eric
Author Profile Icon PIDOUX Eric
PIDOUX Eric
Arrow right icon
View More author details
Toc

Tracking branches


With Git, a branch can track another branch. This allows you to use the commands pull and push, without specifying the branch and repository.

For example, if you clone a Git repository, your local master branch is created as a tracking branch for the master branch of the origin repository.

To set up a tracking branch, execute this:

Jim@local:~/webproject$ git checkout -b new_branch origin/branch_to_track
#Or you can use this
Jim@local:~/webproject$ git branch new_branch origin/master
Jim@local:~/webproject$ git branch --track new_branch origin/master

Similarly, you can specify to not track a remote branch:

Jim@local:~/webproject$ git branch --no-track new_branch origin/master
#You can later update this branch and track origin/master
Jim@local:~/webproject$ git branch -u origin/master new_branch

Deleting a branch from the remote

Use this command if you want to delete a branch in the remote repository:

Erik@local:~/webproject$ git branch -d origin/test
You have been reading a chapter from
Git Best Practices Guide
Published in: Nov 2014
Publisher:
ISBN-13: 9781783553730
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime