【发布时间】:2016-07-03 08:09:17
【问题描述】:
我有一个本地工作区,我想保存在 git 中,直到现在这不是本地 git 存储库。只是工作区 我在 git bash 中所做的步骤
cd 我的工作空间
git 初始化
git 添加。
git commit -m "第一次提交"
git远程添加源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 pull origin master
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 repo 创建为 java 的,所以目前它只有 .gitignore 和 README.md
在谷歌搜索时,我发现将现有工作区签入 git 的步骤是
$ cd my_project
$ git 初始化
$ git add *
$ git commit -m "第一次提交"
$ git remote add origin https://github.com/yourname/my_project.git
$ git pull origin master
$ git push origin master
但我被困在最后一步。
非常感谢!
【问题讨论】:
-
您是否尝试从 URL 或来源中提取?
-
打开 git 配置并检查 origin 是否真的是您正在使用的 url...