I don't know if it was deprecated more recently, but the fact the the git-branch(1) manpage for git-2.7.5 mentions it without warning about it, means it's still around and is going to stay around. I would say it's not quite deprecated but it is discouraged. To set the current branch's upstream to be origin's master. Git branch -set-upstream-to origin/master ![]() Should be and one optinal argument indicating which branch to change, To work around this, introduce -set-upstream-to whichĪccepts a compulsory argument indicating what the new upstream branch As -set-upstream already exists, we can't simply change itsīehaviour. To create a new local branch 'origin/master' that tracks the currentīranch. Usual branch convention of assuming a starting point of HEAD if none The existing -set-uptream option can cause confusion, as it uses the Any version more recent than that should include it. set-upstream-to was introduced in 2012 in the 1.7.12-1.7.13 timeframe. It's related to git branch -set-upstream-to, but not the same. And now you can use git branch -set-upstream-to, but it might be nice if git push could do that automatically-and that's the git push -set-upstream, aka -u, option. Now that they do have a newbranch, your Git creates your origin/newbranch to remember their newbranch. Soon, however, you git push your local newbranch to their Git, so that their Git creates newbranch in their repository. But if you try, it fails: $ git branch -set-upstream-to=origin/newbranchĮrror: the requested upstream branch 'origin/newbranch' does not existīecause origin/newbranch does not exist yet, because the other git at origin does not have a branch named newbranch. That is, suppose you have created a branch newbranch: $ git checkout -b newbranchĪnd want to set its upstream to origin/newbranch. It means that if the push succeeds, your local Git should set, as the upstream of a branch reference supplied as your source, the remote-tracking branch corresponding to the destination branch you got the other Git to set, which in many cases, your own Git has just now created in your repository because their Git has also just created their branch. The git push command has only -u aka -set-upstream, which takes no argument. In your case, you have made other modifications, perhaps mistakes.The git branch command has both -set-upstream and -set-upstream-to, with the former deprecated in favor of the latter for the reason already given in Nick's answer. # Verificando a ligacao `master` -> `origin/master` Nothing to commit, working directory clean (use "git branch -unset-upstream" to fixup) Your branch is based on 'origin/master', but the upstream is gone. $ echo "txt" > file.txt & git add file.txt & git commit -m "Initial commit" # Criação do primeiro commit, necessario para ter um `git status` normal. Warning: You appear to have cloned an empty repository. Initialized empty Git repository in /tmp/remote.git/ $ mkdir remote.git & cd remote.git & git init -bare & cd. Example: # Criação d'um repository remoto When you create a remote repository ( git init -bare ), it has no branch but when you clone the remote into a local repository, the master branch has an upstream link to origin/master, even if origin/master does not yet exists. Git branch master -set-upstream-to=origin/master To summarize, -unset-upstream just deletes a link locally, without deleting any data. Also, git status will no longer show the divergence between yo remote local branch. The consequence of this is just that in a git fetch|pull|push, you will have to manually need the local branch yo remote branch parameters to make the connection. ![]() Answer:ġ/ Push to create the remote branch, then create the missing link: git push origin masterĢ/ Break the local link between master and origin/master : git branch -unset-upstream So I want to understand what this -unset-upstream and why it asks me for it. Why do I need to run this -unset-upstream ? What does this command mean? Did I do something wrong in the previous steps? Afterwards the branches end up working out, but I don't like to do things randomly. (use "git branch –unset-upstream" to fixup)" "Your branch is based on 'origin/master', but the upstream is gone. Now I do a branch called test, and I do add/commit/push.Īnd now here's what I wanted to ask: when I go back to the master branch, the message comes up: Then I clone it locally, create the remote (remote), create a file teste.php and then add/commit/push. I created a project and let it hosted remotely.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |