首页 > 解决方案 > 从旧项目中删除剩余的 git refs

问题描述

我正在做一个项目,现在我想将该文件夹上传到另一个。

我正在尝试运行以下命令:

cd existing_folder
git init
git remote add origin git@gitlab.com:myname/project.git
git add .
git commit -m "Initial commit"
git push -u origin master

但是,我收到错误:

error: src refspec master does not match any
error: failed to push some refs to 'gitlab.com:myname/project.git'

当我尝试推送现有文件夹时。

我从另一个仓库遗留下来的旧遥控器。我删除了那些:

git remote rm origin

但是,我注意到当我尝试运行时裁判仍然给我不正确的数据

git show-ref

我明白了

long code refs/heads/branch-from-old-project
long code refs/heads/branch2-from-old-project
long code refs/stash 

Stash 可能是因为我之前使用过 sourcetree。

任何帮助将不胜感激。有没有办法从旧项目中重置所有这些连接?我尝试重新安装,但没有任何改变。我认为这些裁判可能是问题所在?

标签: gitgitlab

解决方案


所以你说git init在一个已经有.git存储库的文件夹中?这可能不会像你认为的那样做。如果目标是丢弃现有的.gitrepo 并重新开始,那么您确实需要将其丢弃。但是,您当然会失去所有现有的历史!


推荐阅读