I forked the Flask repository and cloned its website branch from GitHub like
git clone --recursive https://github.com/lovesh/flask.git -b website
Then i configured remote like
git remote add upstream https://github.com/lovesh/flask.git -t website
git fetch upstream
Then i made the changes(i didnt create any additional files but modified 2 files) i had to make then added the files and committed the changes like this
git add .
git commit .
This prompted me for a comment for the commit and i entered the comment. Now it showed me
2 files changed, 69 insertions(+), 7 deletions(-)
But when i try to push these changes to my GitHub account
git push origin master
it shows the error
error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/lovesh/flask.git'
I looked around and people who had this issue said that they did not commit the changes as here and here. But i did commit even then it shows me this error. To confirm i tried
git status
and it showed
# On branch website
# Your branch is ahead of 'origin/website' by 1 commit.
#
nothing to commit (working directory clean)
Also git log
also shows my commit in the log. I am new to git. Am i missing something?
First, you don't have a master branch after cloning your repo.git clone
details:
--branch <name>
-b <name>
Instead of pointing the newly created
HEAD
to the branch pointed to by the cloned repository'sHEAD
, point to<name>
branch instead.
In a non-bare repository, this is the branch that will be checked out.--branch
can also take tags and detaches theHEAD
at that commit in the resulting repository.
So in your case, if you want to create and track the local website branch to origin, you need to:
git push -u origin website
(after that, a simple git push
will be enough: more on the push policies in "git - push current
vs. push upstream
(tracking)")
Your other remote 'upstream
' will also only track upstream/website
branch:
The git remote
documentation does mention:
With
-t <branch>
option, instead of the default glob refspec for the remote to track all branches under therefs/remotes/<name>/ namespace
, a refspec to track only<branch>
is created.
You can give more than one-t <branch>
to track multiple branches without grabbing all branches.
In your case, you are only tracking upstream/website
(+refs/heads/website:refs/remotes/upstream/website
) instead of the default refspec (+refs/heads/*:refs/remotes/upstream/*
).
Try git push origin website
May be you configured your master branch under this name. Try and let me know.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With