Marco Fumagalli
Marco Fumagalli

Reputation: 2477

error pushing to a remote branch previously created

I'm not an expert in git.

I've a repo online with master. I created a dev branch using git checkout.

Now I want to commit some local changes just to dev branch.

So i did.

git add file

Then

git commit -m "Dag acquisizione"

I got message

C:\Users\marco.fumagalli\GAIMPORT\dev>git commit -m "Dag acquisizione"
[origin/dev (root-commit) 8ed7bd4] Dag acquisizione
 1 files changed, 236 insertions(+)

Which seems ok to me.

Then if I do

git push -u origin dev

I got an error:

error: src refspec dev does not match any. error: failed to push some refs to 'http://marco.fumagalli@****///*****.git'

Upvotes: 0

Views: 32

Answers (2)

padawin
padawin

Reputation: 4476

You are currently on a branch named origin/dev, not dev. You probably created your branch with:

git checkout -b origin/dev

or something similar.

To fix it, first rename your branch to dev:

git checkout origin/dev # in case you are not on it already
git branch -m dev

then push it as you did:

git push -u origin dev

:+1: to you to use -u by the way.

Upvotes: 2

Shravan40
Shravan40

Reputation: 9898

Assuming you have created your branch on top of master branch of the repository.

 git checkout -b branch_name
 git add file1, file2 ...
 git commit -m "Suitable commit message"
 git push origin branch_name:branch_name

The last command will create a new remote branch with branch_name (if it doesn't exist) and push changes into that particular branch.

Upvotes: 0

Related Questions