By default, when you clone a repository
- that resides at
https://github.com/original/orirepo.git, - whose current branch is called
master,
then
- the local config of the resulting clone lists only one remote called
origin, which is associated with the URL of the repository you cloned; - the local
masterbranch in your clone is set to trackorigin/master.
Therefore, if you don’t modify the config of your clone, Git interprets
git push
as
git push origin master:origin/master
In other words, git push attempts to push your local master branch to the master branch that resides on the remote repository (known by your clone as origin). However, you’re not allowed to do that, because you don’t have write access to that remote repository.
You need to
-
either redefine the
originremote to be associated with your fork, by runninggit remote set-url origin https://github.com/RemiB/myrepo.git -
or, if you want to preserve the original definition of the
originremote, define a new remote (calledmyrepo, here) that is associated to your fork:git remote add myrepo https://github.com/RemiB/myrepo.gitThen you should be able to push your local
masterbranch to your fork by runninggit push myrepo masterAnd if you want to tell Git that
git pushshould push tomyrepoinstead oforiginfrom now on, you should rungit push -u myrepo master
instead.