2

I have a java based dynamic web project in eclipse which is placed under git for source control. I want to upload this project into a repository in bitbucket. To do that, I used the commands below -

git remote add origin https://myself@bitbucket.org/myself/affablebean.git
git push -u origin --all # pushes up the repo and its refs for the first time

The second command gives me an error. Please tell me why this happens and how do I fix it.

error: --all can't be combined with refspecs
usage: git push [<options>] [<repository> [<refspec>...]]

    -v, --verbose         be more verbose
    -q, --quiet           be more quiet.................
    -u, --set-upstream    set upstream for git pull/status
...........................
Tim
  • 2,007
  • 13
  • 24
james
  • 1,427
  • 5
  • 23
  • 37
  • I tried `git push -all origin` instead and the whole project seems to be uploaded. I am not sure if this is the correct way to do things. – james Jul 16 '14 at 18:52
  • No, a `git push -u origin master` is better: see the link I mention in my answer below. – VonC Jul 16 '14 at 20:11
  • Both are fine, depends on what you want to do. If you want to "upload (a) project", I'd say --all is the way to go. – Adam Adamaszek Jul 16 '14 at 20:21

2 Answers2

3

git push with -u sets upstream for a branch, it's a subcommand expecting a refspec (reference specification: branch, commit etc.), so it cannot be used with --all.

git push --all origin is the correct way to do it.

Adam Adamaszek
  • 3,644
  • 1
  • 17
  • 24
2

A simple git push -u origin master should be enough: no need for --all.

That supposes you have added and committed your files locally on the master branch.

See more at "Why do I need to explicitly push a new branch?".

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • It depends. For the first commit pushing multiple branches it is definitely useful to push everything at once… – Knut Jul 16 '14 at 20:13
  • @Knut I agree. But somehow, for a first project to be put under version control, I doubt there were that many branches. – VonC Jul 16 '14 at 20:15
  • That might be totally true… :) – Knut Jul 16 '14 at 20:16