![]() ![]() This creates a branch called bugFix on your remote and sets your local bugFix branch to track it. Found the bug." # Since this is the first time you push to origin $ git push -u origin bugFix $ git commit -m "Put some print statements. # Work on bugFix and then commit the changes $ git add. Just remember to do this the first time you create a branch locally and are ready to push it to the remote: # Create a branch and switch to it $ git checkout -b bugFix After that you can just write git pull and git push on master. Using this flag you are basically telling git to automatically link your local master to the remote master. The -u in this command is a short-hand for -set-upstream. This pushes changes in your local repository up to the master branch of the remote repository origin.īut do you need to do this every time you push? Maybe you use it everyday, or every time you push: $ git push -u origin master You have seen this command in many tutorials. You just have to be careful.ĮDIT: sorry, it is deprecated in commit b347d06bf097aca5effd07871adf4d0c8a7c55bd, but these commits only mention git-branch, not git-push.Do you always need the '-u' in git push -u origin master? 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. 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. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |