Possible Duplicate:
What exactly does the "u" do? "git push -u origin master" vs "git push origin master"
In Github, when you created an empty repository, the instructions ask you to execute
git push -u origin master
So my question is, what’s the use of -u option?
After reading the manpage I still didn’t get it.
git can set a particular branch in a remote repository to be the default “upstream” branch for that particular branch. For example, if you clone an existing repository, git will, by default, associate your
masterbranch with themasterbranch in theoriginrepository, i.e. the one you’re cloning from. This means that git can provide helpful defaults, such as being able to just usegit pullwhile onmasterrather than having to specify a repository and a branch to fetch and merge from. It’s also this association that lets git produce its helpful “Your branch is ahead of origin/master by 10 commits” messages…However, if you haven’t cloned from an exisiting repository, but you’re wanting to set up a new
originremote that represents your newly created GitHub repository, you have to manually tell git to associate yourmasterwithmasterin the neworiginrepository. The-uto git push means “as well as pushing, associate my master branch with the one I’m pushing to”. You only need to do this once for that association to be recorded in.git/config.