Error: src refspec does not match any
The following will create a new branch in local and in remote as well. I follow this when I create a new branch to work with.
git checkout master
git pull origin master
git checkout -b your-branch
Make the new changes
git push -u origin your-branch
You don't appear to have a local branch named test1
. You have a remote branch named test1
associated with your upstream
remote.
You shouldn't be editing the upstream/test1
branch directly. In fact, attempting to check that out should have yielded a warning:
$ git checkout upstream/test1
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
You should instead first check out a local branch that tracks the remote branch, which ought to look something like this:
$ git checkout test1
Branch test1 set up to track remote branch test1 from upstream by rebasing.
Switched to a new branch 'test1'
After doing this, an undecorated git push
would push to the upstream
remote, while git push origin test1
would push to your origin
remote. Adding the -u
flag there would switch the tracking branch so that instead of tracking upstream/test1
, your branch would track origin/test1
, so that future git pull
and git push
operations would refer to that remote branch (origin/test1
) by default.