创建git repo并将本地目录推送到新初始化的Azure Repos

用户名

我创建了本地git回购。(git init,git add,git commit)。然后,我在Azure DevOps上创建了git repo。我也在本地执行git remote add origin <azure_repo_url>

现在,当我尝试git push origin master返回时:

To azure_repo_url
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'azure_repo_url'
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.

因此,我pull尝试git pull origin master但又回来了:

$ git pull origin master
warning: no common commits
remote: Azure Repos
remote: We noticed you're using an older version of Git. For the best experience, upgrade to a newer version.
remote: Found 3 objects to send. (27 ms)
Unpacking objects: 100% (3/3), done.
From azure_repo_url
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
fatal: refusing to merge unrelated histories

我可以解决它git pull origin master --allow-unrelated-histories从这里如此,但我不知道是否有清洁的方式做到这一点?

杰西霍温

在Azure DevOps上创建新存储库时,可以选择对其进行初始化,也可以不进行任何选择。初始化存储库时,Azure DevOps将添加一个.gitIgnore和一个readme.md

在此处输入图片说明

在此处输入图片说明

通常,这是您看到的推/拉问题的原因。

解决此问题的最简单方法是:

git remote add origin <azure_repo_url>
git fetch origin
git rebase master --onto origin/master
... fix any merge conflicts ...
git push origin master

要么:

git remote add origin <azure_repo_url>
git pull --rebase
... fix any merge conflicts ...
git push origin master

最终结果是您将进行本地更改生成了忽略和自述文件。如果遥控器上有更多更改,则可能需要执行更高级的合并,但是如果使用的是干净的遥控器,则应该这样做。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何为CI组织两个git repos

在作为git repos的所有子目录中运行“ git gc”的Powershell命令

克隆/推送Git Repos 443时出错:访问错误,但未使用代理

Azure Repos,使用URL远程创建拉取请求

如何在Azure Repos和管道中使用Git LFS

除了移动到每个目录之外,是否还有git或bash方式来提取多个git repos?

格式化curl以使用clone_url和user:token克隆git repos

以类似GNU存放的方式加入两个git repos

Azure Repos-允许同事提交而无需推送

Azure DevOps中的Repos无法显示git子模块吗?

将代码推送到Google Source Repos错误

货物初始化创建新目录,就像货物新

如何存储废弃项目的git repos?

我嵌套了git repos,会引起问题吗?

Git推送到远程的新存储库,即时进行初始化

Cygwin无法使用现有的Samba上的GIT Repos

将多个外部git repos合并到一个git repo中,并且仍然能够跟踪源

迁移后检查git repos

为什么 git repos 比 SVN repos 小得多?

将多个 git repos 重写为一个

git:关于创建分支和克隆 repos 的问题

Azure Repos Git 与 Azure Databricks 的集成

从远程创建本地 git repo

將 git repos 移動到新的 URI:處理子模塊

在 python 中使用 git 添加用户的所有 repos

如何使用 AzureDevOps 管道和 PowerShell 从 Azure Repos git 下载文件

在一个也是 repo 的目录中初始化 Git,只是没有 .git

在 Azure Repos 中创建分支时强制执行命名/文件夹模式

Azure devops repos 和 TFVC 之间有什么关系,在哪里可以选择 GIT 和 TFVC?