Tracking branches

Using the -u option, we told Git to track the remote branch. Tracking a remote branch is the way to tie your local branch with the remote one; please note that this behavior is not automatic, you have to set it if you want it. When a local branch tracks a remote branch, you actually have a local and a remote branch that can be kept easily in sync (please note that a local branch can track only one remote branch). This is very useful when you need to collaborate with some remote coworkers at the same branch, allowing all of them to keep their work in sync with other people's changes.

To better understand the way our repository is now configured, try to type git remote show origin:

[18] ~/Cookbook (master)
$ git remote show origin
* remote origin
  Fetch URL: https://github.com/fsantacroce/Cookbook.git
  Push  URL: https://github.com/fsantacroce/Cookbook.git
  HEAD branch: master
  Remote branches:
    Pasta   tracked
    Risotti tracked
    master  tracked
  Local branches configured for 'git pull':
    Risotti merges with remote Risotti
    master  merges with remote master
  Local refs configured for 'git push':
    Risotti pushes to Risotti (up to date)
    master  pushes to master  (fast-forwardable)
  

As you can see, the Pasta , Risotti, and master branches are all tracked.

You see also that your local branches are configured to push and pull to remote branches with the same name, but remember: it is not mandatory to have local and remote branches with the same name; the local branch, foo, can track the remote branch, bar, and vice versa; there's no restrictions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.66.13