简体   繁体   English

上传使用 git 克隆复制的项目的一部分

[英]Upload part of a project copied using git clone

Apologies, the answer to this is definitely online somewhere but I had trouble distilling key terms to google, I have a git project consisting of several projects I cloned (just git clone ssh) from another user.抱歉,这个问题的答案肯定在某个地方在线,但我无法将关键术语提取到谷歌,我有一个 git 项目,其中包含我从另一个用户克隆的几个项目(仅 git clone ssh)。 then edited and added my own packages to.然后编辑并添加我自己的包。

When I try to push them to my repository though, the cloned packages show up as links to the repo I cloned from.但是,当我尝试将它们推送到我的存储库时,克隆的包显示为指向我从中克隆的存储库的链接。 At least, it's the symbol that normally means it's a linked package;至少,这个符号通常意味着它是一个链接的 package; in this case you can't actually click on it.在这种情况下,您实际上无法点击它。 I want the copy with my changes to be uploaded, without having to submit a merge request or anything first.我希望上传包含我的更改的副本,而无需先提交合并请求或任何其他内容。

Do I need to fork the original repos to fix this?我需要分叉原始回购协议来解决这个问题吗? Even though I have all the code downloaded locally, in the repo I'm trying to push from?即使我在本地下载了所有代码,在我试图从中推送的回购中?

Edit: None of the submodules I'm trying to remove are listed in the.gitmodules, but I don't know if this is since before or after I tried removing them.编辑:我尝试删除的所有子模块都没有列在 .gitmodules 中,但我不知道这是在我尝试删除它们之前还是之后。 I want to try adding them back in manually then doing another attempt at git submodule deinit, but will this remove all local edits I made to them?我想尝试手动添加它们,然后再次尝试 git 子模块 deinit,但这会删除我对它们所做的所有本地编辑吗?

Not sure if I got the question correctly, but I think the term yo are looking for is git remote .不确定我是否答对了问题,但我认为你正在寻找的术语是git remote

git remote remove origin
git remote add origin yourRepo

These 2 commands will "unlink" project from its original repo and link to yours.这 2 个命令将从其原始存储库“取消链接”项目并链接到您的项目。

To remove a submodule from your tree, you can do so using git rm .要从树中删除子模块,可以使用git rm来完成。 To remove the submodule and add its files back as part of the outer repository needs some extra steps:要删除子模块并将其文件添加回外部存储库的一部分,需要一些额外的步骤:

You should backup first (just do a cp -r of the outer repository if you want to be sure), to make sure you don't lose any unpushed changes!你应该先备份(如果你想确定的话,只需对外部存储库执行cp -r ),以确保你不会丢失任何未推送的更改!

# Move the submodule first - otherwise the directory will be deleted when you do git rm!
mv submoduleDir sobmoduleDirBak
git rm submoduleDir
mv submoduleDir2 submodileDir
# Before adding the directory back, we have to remove its .git
rm -rf submoduleDir/.git
git add submoduleDir

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM