$ git status On branch master Your branch is ahead of 'origin/master' by 3 commits. ... $ git push origin Tim_Musharapov error: src refspec Tim_Musharapov does not match any. error: failed to push some refs to '...' 

Why can't I push?

    2 answers 2

    error: src refspec Tim_Musharapov does not match any

    This means that the origin repository simply does not have a branch named Tim_Musharapov . It needs to be created. The syntax for creating branches is:

      git push origin что:куда 

    Here, что is the local branch that you want to push, and куда is the name of the new branch to origin, into which you want to push the branch что . And origin is the name of the remote repository (remote), it may be different, but this is the default.

    Therefore, the variant git push origin master:Tim_Musharapov proposed in the next answer git push origin master:Tim_Musharapov means "Take the local master branch and push to the newly created Tim_Musharapov branch". It works, but there will be a mismatch in the names of local and remote branches. And the master branch is now busy with your own work and it has become inconvenient to receive updates from the master branch of the origin repository:

    Your branch is ahead of 'origin / master' by 3 commits

    There are three of your commits in your master branch, so git pull to this branch will not work anymore.

    There is a common practice: call local and remote branches the same way. This is not necessary (ie, Git allows you to do it differently), but it is convenient and practical. Accordingly, if you cannot change the remote branch of the master then do not make changes in the course of work in the local master .

    Therefore, I propose this solution:

    First we need a branch in which we will commit the results of our work. It may be called, for example, Tim_Musharapov , but usually a branch is called by the problem being solved , and not by the name of the developer.

    If there is no such branch yet, it must be created so that it duplicates the master (looking at the same commit).

     git checkout -b Tim_Musharapov master 

    If there is already a branch, update it to the current master:

     git checkout Tim_Musharapov git merge --ff-only master # если конфликт, значит там есть какие-то изменения, которых нет в master # нужно смотреть и разбираться. 

    push it to origin, the -u switch keeps the correspondence between the local and remote branches

     git push -u origin Tim_Musharapov:Tim_Musharapov # в следующий раз из этой ветки можно будет пушить проще: git push 

    And the master branch will return to the state as on the remote

     git checkout master git reset --hard origin/master # В локальную ветку master мы будем получать обновления с origin git checkout master git pull 

    A little more about the syntax что:куда :

     git checkout somebranch # Оба варианта создают одноимённую ветку на origin git push origin -u somebranch git push origin -u somebranch: # Запушить "ничего" в ветку - значит удалить её git push origin :otherbranch 
    • Nick, tell me how it was possible to duplicate the changes from master to another branch (if it already exists on the local repository) - this is where it all started, just started making changes in the local master. - Timur Musharapov
    • @TimurMusharapov So I already wrote. git branch name or git checkout -b name creates a new name branch that looks at the same commit as the current one. - Nick Volynkin
    • And if it already exists, just the changes are a bit old (all within the local repository)? - Timur Musharapov

    Because there is a binding to the main branch. Do this:

     git push origin master:Tim_Musharapov 
    • Oh, you're right! Please tell us more about it or give a link where you can read. - Timur Musharapov
    • If my answer helped - mark it, please, as "True." Link: git-scm.com/docs/git-push - Alexandr Blinov