Git needs the name of the new branch it should create.When we choose to create a new branch-with git branch, git checkout -b, or git switch -c-we must give Git two things: The git push will this time call up origin and attempt to have the Git repository at origin update that other Git repository's branch br1 (the branch on the other Git that we remember, locally, as origin/br1). However, if we then run: git branch -set-upstream-to=origin/br1 We will get an error from git push because the name br2 in origin/br2 does not match the name br1. If we run: git branch -set-upstream-to=origin/br2 If this is set to simple-as it normally is today-this kind of git push will only push to the upstream of the current branch, and only if the upstream is set to a remote-tracking name that-once the remote part is removed-matches the current branch.įor example, suppose the current branch is named br1, and both origin/br1 and origin/br2 exist. In command line Git, the behavior git push, with no additional arguments, is controlled by the fault setting. a remote-tracking name like origin/somebranch.If it had no upstream before, this operation does nothing otherwise, it removes the upstream setting. To unset the upstream, use git branch -unset-upstream: git branch -unset-upstream If it previously had origin/otherbranch set as its upstream, that upstream is now removed, because only one upstream can be set: origin/somebranch is now the upstream. The current branch now has origin/somebranch set as its upstream (unless the command failed, in which case nothing has changed). To set a particular upstream, use git branch -set-upstream-to: git branch -set-upstream-to=origin/somebranchįor instance. A branch either has an upstream set, or does not have an upstream set. That said, each branch, in Git, can have one upstream set. It's like assuming that a 1980s-era automobile has self-driving capability. It's important to know and understand this if you think that branches mean something in Git, you will eventually hurt yourself. Important backgroundīranches are not created from branches. Visual Studio apparently (mis)uses this to decide to ask the remote to update its test branch. It's because the upstream of your new branch is set to origin/test.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |