Java 将本地工作区签入新的git repo
我有一个本地工作区,我想保存在git中,直到现在这还不是一个本地git repo。只是工作区 我在git bash中执行的步骤 cd myworkspace git初始化 git添加 git提交-m“首次提交” git远程添加源 git推送源主机Java 将本地工作区签入新的git repo,java,eclipse,git,github,Java,Eclipse,Git,Github,我有一个本地工作区,我想保存在git中,直到现在这还不是一个本地git repo。只是工作区 我在git bash中执行的步骤 cd myworkspace git初始化 git添加 git提交-m“首次提交” git远程添加源 git推送源主机 warning: no common commits remote: Counting objects: 4, done. remote: Compressing objects: 100% (3/3), done. remote: Total 4 (
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
这样做我犯了一个错误
! [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
任何人都可以帮我解决这个错误
注意:我创建了一个java版的git repo,所以目前它只有
.gitignore和README.md
在谷歌搜索时,我发现将现有工作区签入git的步骤如下
$cd my_项目
$git init
$git添加*
$git commit-m“首次提交”
$git远程添加源
$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推送原始主机
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
但我被困在最后的第二步
非常感谢 这里的问题是您已经在本地工作区中初始化了存储库,其中已经包含了一些文件。当您在GitHub上创建存储库并使用.gitignore和README.md初始化它时,它还包含一些文件 当您推送项目时,git将拒绝,因为它不知道如何合并您的内容 这里有一些解决方案
您是否尝试从URL或源代码中提取?打开git配置,检查源代码是否确实是您正在使用的URL…在您正确指出原因后,解决方案变得简单,非常感谢。工作得很有魅力。另一个帮助是,当我使用gitbash时,gitignore可以完美地工作,但在使用eclipse git插件时,即使我在[eclipse]中添加了模式: