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