From: Oleg Broytman Date: Fri, 26 Jun 2015 23:07:01 +0000 (+0300) Subject: Rename remote branches to remote-tracking ones X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=6261a0843483ab208cab4c8e88b11cda2ef2a7e7;p=git-wiki.git Rename remote branches to remote-tracking ones --- diff --git a/pep-git.txt b/pep-git.txt index a96594d..74584f6 100644 --- a/pep-git.txt +++ b/pep-git.txt @@ -119,11 +119,11 @@ done something like that:: The first command clones remote repository into local directory `python``, creates a new local branch v2, sets remotes/origin/v2 as -its upstream remote branch and checks it out into the working +its upstream remote-tracking branch and checks it out into the working directory. The last command creates a new local branch v1 and sets -remotes/origin/v1 as its upstream remote branch. +remotes/origin/v1 as its upstream remote-tracking branch. The same result can be achieved with commands:: @@ -131,9 +131,9 @@ The same result can be achieved with commands:: $ cd python $ git checkout --track origin/v2 -The last command creates a new local branch v2, sets -remotes/origin/v2 as its upstream remote branch and checks it out into -the working directory. +The last command creates a new local branch v2, sets remotes/origin/v2 +as its upstream remote-tracking branch and checks it out into the +working directory. Branches and branches @@ -152,43 +152,39 @@ freely. Remote repositories and remote branches ======================================= -Another example of slightly misleading terminology. Remote -repositories are really remote, you access them via network (well, a -remote repository can be on your local disk, but it's still remote -because it's not the current repo). +Remote-tracking branches are branches (pointers to commits) in your +local repository. They are there for you to remember what branches and +commits have been pulled from and pushed to what remote repos (you can +pull from and push to many remotes). Remote-tracking branches live +under ``remotes/REMOTE`` namespaces, e.g. ``remotes/origin/v2``. -Remote branches, on the other hand, are branches (pointers to commits) -in your local repository. They are there for you to remember what -branches and commits have been pulled from and pushed to what remote -repos (you can pull from and push to many remotes). Remote branches -live under ``remotes/REMOTE`` namespaces, e.g. ``remotes/origin/v2``. - -To see the status of remote branches run:: +To see the status of remote-tracking branches run:: $ git branch -rv -To see local and remote branches (and tags) pointing to commits:: +To see local and remote-tracking branches (and tags) pointing to +commits:: $ git log --decorate -You never do your own development on remote branches. You create a -local branch that has a remote branch as upstream and do development -on that local branch. On push git pushes commits to the remote repo -and updates remote branches, on pull git fetches commits from the -remote repo, updates remote branches and fast-forwards, merges or -rebases local branches. +You never do your own development on remote-tracking branches. You +create a local branch that has a remote branch as upstream and do +development on that local branch. On push git pushes commits to the +remote repo and updates remote-tracking branches, on pull git fetches +commits from the remote repo, updates remote-tracking branches and +fast-forwards, merges or rebases local branches. When you do an initial clone like this:: $ git clone -b v1 http://git.python.org/python.git git clones remote repository ``http://git.python.org/python.git`` to -directory ``python``, creates remote branches, creates a local branch -``v1``, configure it to track upstream remotes/origin/v1 branch and -checks out ``v1`` into the working directory. +directory ``python``, creates remote-tracking branches, creates a +local branch ``v1``, configure it to track upstream remotes/origin/v1 +branch and checks out ``v1`` into the working directory. -Updating local and remote branches ----------------------------------- +Updating local and remote-tracking branches +------------------------------------------- There is a major difference between @@ -209,9 +205,9 @@ update any branch (doesn't move any pointer). The second command fetches commits from the named BRANCH in the REMOTE repository that are not in your repository and updates both the local -branch BRANCH and its upstream remote branch. But it refuses to update -branches in case of non-fast-forward. And it refuses to update the -current branch. +branch BRANCH and its upstream remote-tracking branch. But it refuses +to update branches in case of non-fast-forward. And it refuses to +update the current branch. The first command is used internally by ``git pull``. @@ -278,11 +274,11 @@ git guesses (knowing upstream remote branches) that you really want $ git push origin v1:v1 v2:v2 -Git pushes commits to the remote repo and updates remote branches. Git -refuses to push commits that aren't fast-forwardable. You can -force-push anyway, but please remember - you can force-push to your -own repositories but don't force-push to public or shared repos. If -you find git refuses to push commits that aren't fast-forwardable, +Git pushes commits to the remote repo and updates remote-tracking +branches. Git refuses to push commits that aren't fast-forwardable. +You can force-push anyway, but please remember - you can force-push to +your own repositories but don't force-push to public or shared repos. +If you find git refuses to push commits that aren't fast-forwardable, better fetch and merge commits from the remote repo (or rebase your commits on top of the fetched commits), then push. Only force-push if you know what you do and why you do it. See the section `Commit @@ -346,14 +342,14 @@ It is possible to recover from forced push but it's PITA for the entire team. Please avoid it. To see what commits have not been published yet compare the head of the -branch with its upstream remote branch:: +branch with its upstream remote-tracking branch:: $ git log origin/v2.. $ git log origin/v1..v1 -For every branch that has an upstream remote branch git maintains an -alias @{upstream} (short version @{u}), so the commands above can be -given as:: +For every branch that has an upstream remote-tracking branch git +maintains an alias @{upstream} (short version @{u}), so the commands +above can be given as:: $ git log @{u}.. $ git log v1@{u}..v1