35

I have an empty project on remote, which I cloned. Now I want to start working on a branch, testdev and start working on it without putting any code to master.

$ git checkout -b testdev
$ git status
On branch testdev

Initial commit

nothing to commit (create/copy files and use "git add" to track)

Now I try to push this branch to bitbucket

$ git push origin testdev

error: src refspec testdev does not match any.
error: failed to push some refs to 'https://username@bitbucket.org/myremoterepo.git'

I tried git add . and git commit -m "msg" but that is useless as I don't have any files to track or commit. So how do I push an empty branch to an empty project?

yayu
  • 7,120
  • 17
  • 49
  • 80

1 Answers1

68

If you repo is still empty, you might try and create an empty commit, to have something to push:

git commit --allow-empty -m "initial commit"
git push -u origin testdev

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

Community
  • 1
  • 1
VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755