我有一个本地的git项目,我想添加到gitolite。显然这很难,所以我放弃了这个想法。我创建了一个新的gitolite存储库,将其添加到gitolite-admin/conf/gitolite.conf,并提交和推送更改。然后我成功地用git clone git-noah:project-name
克隆了新的repo。然后我将除.git之外的所有文件和文件夹复制到项目名称文件夹。是的
git add -A
git commit -a -m "Moved to new repo."
git push
字符串
我得到这个错误:
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'git-noah:project-name'
型
7条答案
按热度按时间czq61nw11#
在远程(源)存储库上还不存在“main”。
字符串
在第一次推送之后,您可以使用更简单的
型
**编辑:**随着最近的趋势,我的答案已经更新,以取代“主”与“主”
y0u0uwnf2#
如果收到错误:
字符串
但未接收错误:
型
在尝试运行
git push
之前,请确保已运行git commit
toiithl63#
如果你使用git镜像,那么使用这个:
字符串
dfddblmv4#
您的master分支可能位于上游,需要在分支master上取消设置
你的分支是基于'origin/master'的,但是上游没有了。(使用
git branch --unset-upstream
进行修复)omjgkv6w5#
在已接受的答案下面选择this user的评论。
我在使用
fast-export
从hg Mercurialrepo移动到GitLabrepo时遇到了这个错误,当时GitLab仓库已经在一段时间前创建了,并且仍然是空的。错误的原因是新GitLab仓库的这个空框架已经构建了主分支应该被称为“master”的设置。这也是该消息所暗示的:
Perhaps you should specify a branch such as 'master'.
个在您的例子中,您可能有一个迁移工具,默认情况下将分支名称切换为
main
。在我的例子中,我已经将参数-M -main
添加到fast-export
命令中,将名称更改为现在更常见的main
-然后与已经设置的GitLab存储库中所需的master
冲突。在git-repo文件夹中,我运行了(错!):
字符串
因此,我回到开始,在没有
-M -main
的情况下再次尝试:我删除了git-repo文件夹中的.git
文件夹,再次运行git init my_git_repo
,然后运行fast-export
命令,而不运行-M -main
。然后一切工作:我可以git checkout HEAD
,git remote add origin git@gitlab.com:my_project-url.git
,git branch
,git push -u origin --all
和git push -u origin --tags
。wa7juj8i6#
对我来说,我有未提交的文件。
运行
git status
已添加所有文件
git add .
运行
git push
然后,
git push origin main
或master8nuwlpux7#
您的本地和远程存储库不共享相同的历史,因为您重新创建了存储库。因此,Git不会让你推送这些内容。
如果您不怕丢失远程仓库中的内容,可以强制推送:
git push -f
。