1

I created a branch with the command:

git checkout -b add-foo-bar-to-foo

and after committing changes, I am trying to push my changes with the command:

git push origin feature/add-foo-bar-to-foo

But it is failing with the error:

error: src refspec feature/add-foo-bar-to-foo does not match any.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Kapil Mediratta
  • 89
  • 1
  • 1
  • 6

1 Answers1

2

Make sure you do have a branch feature/add-foo-bar-to-foo, with git branch.
Because git checkout -b add-foo-bar-to-foo creates an add-foo-bar-to-foo branch, not a feature/add-foo-bar-to-foo.

So your first push should be:

git push -u origin add-foo-bar-to-foo

The -u is for establishing a tracking relationship between the local branch add-foo-bar-to-foo and its remote tracking branch origin/add-foo-bar-to-foo (upstream branch).

After that, a simple git push will be enough (git will know what branch to push and where)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Note that you can specify the branch you want to push to on the remote by seperating the references with a colon (`:`): `git push -u origin add-foo-bar-to-foo:feature/add-foo-bar-to-foo`. This would push a local branch `add-foo-bar-to-foo` to the remote branch `feature/add-foo-bar-to-foo`. – Sascha Wolf Oct 22 '14 at 06:52