0

My previous step was

git remote set-url origin https://github.com/MilenkoM/ex1microhydra.git

git remote -v 

shows

origin  https://github.com/MilenkoM/ex1microhydra.git (fetch)
origin  https://github.com/MilenkoM/ex1microhydra.git (push)

If I go for

git push origin master

then I got error

error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/MilenkoM/ex1microhydra.git'

Why? Git log shows

commit 0e9a31ff7c1fb1d0bb56e8ad5a359f92666be6a9 (HEAD -> mybranch)
Date:   Wed Dec 18 17:12:21 2019 +0100

     Changes to be committed:
            new file:   index.js
            new file:   package.json

I followed the advice from Loi and eftshift,and tried this

git checkout master

Switched to branch 'master'

It doesn't work either

git push origin mybranch:master

Says

To https://github.com/MilenkoM/ex1microhydra.git
 ! [rejected]        mybranch -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/MilenkoM/ex1microhydra.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I am new to git,what are these fast-forwards?

 git show-ref
8ef0e288bb2ab7c42ebc37b018fcb08a73073c2e refs/heads/master
0e9a31ff7c1fb1d0bb56e8ad5a359f92666be6a9 refs/heads/mybranch
097e48b3fd8f87f90f19872fc788ea2f0bb433cc refs/remotes/origin/master

I should go for pull,but pull what?

8
  • Try git checkout -b "master" before push to see if it works (of course also merge the necessary changes from your mybranch before push) Commented Dec 24, 2019 at 16:22
  • Switched to a new branch 'master' Commented Dec 24, 2019 at 16:37
  • Try the answer below, it sounds promising (remember git checkout mybranch again first) Commented Dec 24, 2019 at 16:38
  • stackoverflow.com/…
    – phd
    Commented Dec 24, 2019 at 17:12
  • stackoverflow.com/…
    – phd
    Commented Dec 24, 2019 at 17:14

1 Answer 1

1

Looks like you don't have a local branch called master. If you want to push your mybrancy branch into remote master, you do it like this:

git push origin mybranch:master

Not the answer you're looking for? Browse other questions tagged or ask your own question.