Git Push into an Empty Repository 错误:未能将一些引用推送到
Posted
技术标签:
【中文标题】Git Push into an Empty Repository 错误:未能将一些引用推送到【英文标题】:Git Push into an Empty Repository error: failed to push some refs to 【发布时间】:2020-07-29 20:40:18 【问题描述】:当我执行 git push --set-upstream origin master
时,我在将 GIT 推送到空存储库时遇到此错误。
在 Windows 上,我输入项目的文件夹:
git init
git remote add origin https://almatoolbox.visualstudio.com/xxxxxxx/_git/TS_smartroad-tests
git add .
git commit
git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin master
然后我输入:
git push --set-upstream origin master
但我有这个错误:
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://almatoolbox.visualstudio.com/ANAS/_git/TS_smartroad-tests'
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.
我想将我的项目文件夹部署到分支 master 并进行开发。可能吗? 如果我做 git pull origin master 我有这个错误:
git pull origin master
From https://almatoolbox.visualstudio.com/ANAS/_git/TS_smartroad-tests
* branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories
git remote -vv
origin https://almatoolbox.visualstudio.com/xxxxxxx/_git/TS_smartroad-tests (fetch)
origin https://almatoolbox.visualstudio.com/xxxxxxx/_git/TS_smartroad-tests (push)
我的分支是:
git branch -vv
develop 87d2624 [origin/develop] Deleted pom.xml
* master 824e4a7 ok
【问题讨论】:
您是否阅读了 git 错误中的指南,或任何(非常多)Qs、As、博客文章和关于该问题的文章? 阅读错误信息中的hint
远程是空的!!!如果我做 git pull:我有错误:git pull origin master From almatoolbox.visualstudio.com/xxxxxxxx/_git/TS_smartroad-tests * branch master -> FETCH_HEAD 致命:拒绝合并不相关的历史
你的遥控器肯定不是空的。您已经创建了一个存储库并使用README
或.gitignore
对其进行了初始化。查看差异:git fetch origin && git diff origin/master HEAD
【参考方案1】:
您的遥控器不是空的。这正是错误消息告诉您的内容。
证明:
-
运行
git fetch --all
然后git log --graph --oneline --all
您将看到origin/master
,这是对远程现有主分支的引用。根据 git 的配置方式,它和任何其他远程分支将被涂成红色。
⚠️ 警告:我犹豫是否给你以下信息,因为你表现出不了解 git 的迹象,并冒着造成无法挽回的风险的风险。 风险自负。
如果您绝对确定不希望 origin/master
中的任何现有提交,例如如果 @phd 正确,它只是 GitHub 创建的默认 README
1,您可以:
git checkout master
(以确保您在本地主控)
git push --force
:这将覆盖您遥控器上的master
。
1当您创建一个新的 GitHub 存储库时,可以告诉它不要使用默认的 README.md
创建初始提交
【讨论】:
以上是关于Git Push into an Empty Repository 错误:未能将一些引用推送到的主要内容,如果未能解决你的问题,请参考以下文章
Git 报错:fatal: destination path ‘.‘ already exists and is not an empty directory.
Git 报错:fatal: destination path ‘.‘ already exists and is not an empty directory.
#yyds干货盘点# Git 报错:fatal: destination path ‘.‘ already exists and is not an empty directory.
git push到远程仓库时出现Git Push Error: insufficient permission for adding an object to repository database(
git push 报错 fatal: unable to access 'https://github.com/TANG422/AOXINa.git/': OpenSSL SSL_re