Git未能将新项目提交给GitHub”;拒绝合并不相关的历史记录”;
Git拒绝向GitHub提交新项目 我尽了一切可能 这不是一个特定的错误,似乎有多个错误 我需要键入哪些命令才能进行此提交 这是控制台打印输出,为internet编辑Git未能将新项目提交给GitHub”;拒绝合并不相关的历史记录”;,git,github,Git,Github,Git拒绝向GitHub提交新项目 我尽了一切可能 这不是一个特定的错误,似乎有多个错误 我需要键入哪些命令才能进行此提交 这是控制台打印输出,为internet编辑 D:\>cd D:\Projects\TestProject D:\Projects\TestProject>git init Initialized empty Git repository in D:/Projects/TestProject/.git/ D:\Projects\TestProject>g
D:\>cd D:\Projects\TestProject
D:\Projects\TestProject>git init
Initialized empty Git repository in D:/Projects/TestProject/.git/
D:\Projects\TestProject>git add .
D:\Projects\TestProject>git commit -m "First Commit"
[master (root-commit) 525f262] First Commit
17 files changed, 976 insertions(+)
create mode 100644 TestProject.sln
create mode 100644 TestProject/App.config
create mode 100644 TestProject/Form1.Designer.cs
create mode 100644 TestProject/Form1.cs
create mode 100644 TestProject/Form1.resx
create mode 100644 TestProject/Properties/AssemblyInfo.cs
create mode 100644 TestProject/Properties/Resources.Designer.cs
create mode 100644 TestProject/Properties/Resources.resx
create mode 100644 TestProject/Properties/Settings.Designer.cs
create mode 100644 TestProject/Properties/Settings.settings
D:\Projects\TestProject>git remote add origin https://github.com/TestAccount/TestProject
D:\Projects\TestProject>git remote -v
origin https://github.com/TestAccount/TestProject (fetch)
origin https://github.com/TestAccount/TestProject (push)
D:\Projects\TestProject>git push origin master
To https://github.com/TestAccount/TestProject
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/TestAccount/TestProject'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
第一次推送失败,按照指示进行推送
D:\Projects\TestProject>git pull
warning: no common commits
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/TestAccount/TestProject
* [new branch] master -> origin/master
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> master
D:\Projects\TestProject>git push origin master
To https://github.com/TestAccount/TestProject
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/TestAccount/TestProject'
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.
D:\Projects\TestProject>git pull --rebase
There is no tracking information for the current branch.
Please specify which branch you want to rebase against.
See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> master
D:\Projects\TestProject>git status
On branch master
nothing to commit, working tree clean
D:\Projects\TestProject>git branch
* master
D:\Projects\TestProject>git pull origin master
From https://github.com/TestAccount/TestProject
* branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories
D:\Projects\TestProject>git branch --set-upstream-to=origin/master master
Branch 'master' set up to track remote branch 'master' from 'origin'.
D:\Projects\TestProject>git pull
fatal: refusing to merge unrelated histories
将添加的文件移回目录
D:\Projects\TestProject>git clone https://github.com/TestAccount/TestProject
Cloning into 'TestProject'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
D:\Projects\TestProject>git add .
D:\Projects\TestProject>git commit -m "Second Commit"
[master 41b46fc] Second Commit
18 files changed, 2 insertions(+)
create mode 100644 TestProject.sln
create mode 100644 TestProject/App.config
create mode 100644 TestProject/Form1.Designer.cs
create mode 100644 TestProject/Form1.cs
create mode 100644 TestProject/Form1.resx
create mode 100644 TestProject/Properties/AssemblyInfo.cs
create mode 100644 TestProject/Properties/Resources.Designer.cs
create mode 100644 TestProject/Properties/Resources.resx
create mode 100644 TestProject/Properties/Settings.Designer.cs
create mode 100644 TestProject/Properties/Settings.settings
create mode 100644 TestProject/README.md
D:\Projects\TestProject>git push
To https://github.com/TestAccount/TestProject
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/TestAccount/TestProject'
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.
D:\Projects\TestProject>git pull
fatal: refusing to merge unrelated histories
固定
git pull origin master --allow-unrelated-histories
git merge origin origin/master