push master, or push all?

per_qadb
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 13, 2016

Hi, a newbie question: Following the instruction on how to set up a local repo and then get it over to Bitbucket, I think I managed to successfully do the command:

$ git push -u origin master

That 's the last of two commands I pasted from the Bitbucket Overview page. But maybe I should only have done the 'remote add origin' thing (the first command)?

Then , the instruction says I should do:

$ git push -u origin --all

But is this necessary? Do I really need to push twice? I don't know the difference between "master" and "all". Tell me if I did anything wrong here.

2 answers

1 accepted

1 vote
Answer accepted
Steven Whitman
Contributor
December 13, 2016

The instructions on the overview page assume you are only pushing one branch, master.  If you have a repo that contains many branches then you need to push the all with the 'git push --mirror origin' to push all refs under refs/ (which may include but is not limited to refs/heads/, refs/remotes/, and refs/tags/). See the documentation for git push for other options.  For example you could also do a 'git push --all origin' to push just branches and not tags.

per_qadb
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 13, 2016

Thank you very much! No, what I'm aware of there is only one branch. A "branch" is something you can create, when already working with Git, or Mercurial, e.g. to be able to experiment with some creative idea that you're kind of unsure of?

 

Steven Whitman
Contributor
December 13, 2016

With one branch 'git push -u origin master' will work just fine assuming the one branch you are referring to is the master branch.  Branches are used for many things.  They can be used to isolate experimental work as you describe. They can be used for implementing bugfixes, new features, releases, etc.  There are a number of resources online that describe various git branch strategies.  Here is a link from Atlassian's site: https://www.atlassian.com/git/tutorials/comparing-workflows/ but there are many more.

2 votes
Alexey_Efimov
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 13, 2016

Hello,

Please look at https://git-scm.com/book/en/ch2-5.html#Pushing-to-Your-Remotes

So, -u is connect you local branch master to remote branch origin/master after push.

If you use --all, then all local branches will pushed on server.

After your local branch is connected to remote branch, you can simple use git push, without specification remote and branch. It will push current branch into connected remote branch.

bxk10
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 1, 2018

nice

Vishwanath kota
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 1, 2019

Great. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events