我有一个本地工作区,希望将其保存在git中,直到现在它还不是本地git仓库。以下是我在git bash中的步骤:
cd myworkspace git init
git add .
git commit -m "第一次提交"
git remote add origin https://github.com/username/eclipse.git git push origin master 这样做时出现了错误。
cd myworkspace git init
git add .
git commit -m "第一次提交"
git remote add origin https://github.com/username/eclipse.git git push origin master 这样做时出现了错误。
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/username/eclipse.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.
接着我执行了以下操作:
git拉取远程代码至本地主分支
warning: no common commits
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://github.com/koushikpaul1/eclipse
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
fatal: refusing to merge unrelated histories
请问有人能帮我解决这个错误么:
注意:我创建的git仓库是一个java仓库,因此它目前只包含.gitignore和README.md文件。
在搜索时,我发现将现有的工作空间存入git的步骤如下:
$ cd my_project
$ git init
$ git add *
$ git commit -m "第一次提交"
$ git remote add origin https://github.com/yourname/my_project.git
$ git pull origin master
$ git push origin master
但是我卡在了倒数第二步
非常感谢!