![]() But a remote-tracking branch will not be created locally. If the branch name does not exist in the remote repository, it will be created. (b) git push -u If we try to push a local branch to a remote repository without having a remote-tracking branch then we have to specify the remote name and the branch name it will be pushed. However, when we try to checkout one of these remote branches, git will create the necessery local branch. So when you run git branch -a, you’ll see something like this: $ git branch -a (a) git clone – it fetches all remote branches, creating remote-tracking branches as well, but only creates one local branch, master, for you. (b) When we do “git push” or “git pull” without specifying remote or branch, it will use the relation defined by the remote-tracking branch to select the appropriate remote and branch.ĭefining a remote-tracking branch can be done by: # Your branch is ahead of 'origin/branch1' by 1 commit. Keep in mind that this information may not be updated and so it may not reflect the current situation of the remote branch. ![]() (a) When we execute “git status”, is used to compare the local to the remote branch, based on the information that is containen in the remote-tracking branch. As the Pro Git book suggests, “think of them as bookmarks, to remind you where the branches in your remote repositories were the last time you connected to them”. Git automatically updates them when you communicate with the remote branch (e.g when you execute git fetch or git pull and so on). There is nothing we can do about it, locally. It just reflects the status of the remote branch. Because it works like an image, the remote-tracking branch cannot be edited locally. ![]() It works like an image of the remote branch that helps us to assess the status of the local branch comparing to the remote. Which means, the remote-tracking branch exists locally. This relation includes mainly information about the status of the remote branch. The branch pointer represents two and only things: (a) the commit which the initial files of the working directory came from, before you started making changes and (b) the commit that will contain whichever changes from your working directory you decide to “save” just after you save (commit) them.Ī remote-tracking branch is just a relation of a local branch to a remote branch. A local branch is a pointer pointing on a specific local commit aka on a commit in the local git repository. But you have to deal with them as you soon as you master the Git basics and, of course, if you are planning to work in a team environment. First, let’s make it clear one more time that a branch is nothing more that a reference. Remote-tracking branches is an advanced concept not easily understood by newcomers to the Git world.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |