What happens if I pulled an unnecessary branch?

Consider the following thread:

1) git checkout -b newbranch

2) Make some commits ....

3)

 git push 

Observation

  • newbranch does NOT track remote
  • a new branch was created on the bitbucket: 'newbranch'

Why can I click pull from this thread? I just read http://git-scm.com/book/ch3-5.html and as far as I understand this should not work.

Because I can use "newbranch" in collaboration with others, merging, etc.

Basically, I do not see the difference between the tracking branch and the branch without tracking. Perhaps this is due to the fact that I use only git for special cases when the difference does not matter?

Comment: I understand tracking and how to set it up. The problem is that I don’t understand why the installation without tracking works the way it is. I also realized that I used git like this for a while

As stated in the comments:

 $ git config -l user.email=********$ user.name=********* push.default=current color.ui=true core.editor=vim credential.helper=cache --timeout=3600 core.repositoryformatversion=0 core.filemode=true core.bare=false core.logallrefupdates=true remote.origin.url=******** remote.origin.fetch=+refs/heads/*:refs/remotes/origin/* branch.master.remote=origin branch.master.merge=refs/heads/master 

-

+4
source share
2 answers

This is due to the push.default value in the git configuration.

From git-config

current - click the current branch to update the branch with the same name on the receiving side. Works in both central and off-center work processes.

This means that git simply looking for a branch with the appropriate name on the server. If you change this value to upstream (or simple for this question), you will not be able to click on raw branches, and current and matching will also allow you to click on untracked branches.

+2
source

Tapping a non-tracking branch still pushes that branch. It just doesn't set up tracking. Entries in this thread are placed on the remote computer. A branch on the remote server is created with the same name and will contain the same commits, but Git simply does not track changes on this remote branch in your local branch.

The root reason you can click and extract from this branch is because of how Git commits. Each commit has a parent commit, regardless of whether these commits are part of the tracking branch. In principle, commits are a linked list. Pushing and pulling, which actually just merge under the hood, is done on the basis of commits, and not the fact that the branch is "tracking" another branch.

+1
source

All Articles