Reputation: 1346
I created new repository ([email protected]:derkode/ForvoClient.git) and did SSH Key, then:
git config --global user.email "[email protected]"
git config --global user.name "my_nickname"
git config --global push.default simple
git init
git add *
git commit -m "First commit"
git remote add origin [email protected]:derkode/ForvoClient.git
But after: git push -u origin master
! [rejected] master -> master (non-fast-forward) error: failed to push some refs to '[email protected]:derkode/ForvoClient.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Merge the remote changes (e.g. 'git pull') hint: before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
What is it?
Upvotes: 0
Views: 98
Reputation: 124646
Your repo on GitHub already has a commit.
https://github.com/derkode/ForvoClient
This is normal when you create a repo with a README file.
You can fix this either by force pushing your local repo to GitHub, but you will lose the README file this way:
git push -u origin master -f
Or, you can merge the version on GitHub into yours and then push it back:
git pull origin master
git push -u origin master
Or, as @xbonez suggested, rebase your version on top of GitHub's version:
git fetch origin
git rebase origin/master
git push -u origin master
Upvotes: 3
Reputation: 42440
If you want to get rid of the commit that Github created for you with the README file, follow janos
's answer. If you want to keep that commit, and push yours over it, simply pull down those changes and then push:
git fetch origin && git rebase origin/master && git push origin master
Upvotes: 1