更改现有 Xcode 项目的 Git 存储库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28272357/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:35:28  来源:igfitidea点击:

Change Git Repository Of Existing Xcode Project

xcodegitgithubgit-clone

提问by Tom Metzger

I cloned an abandoned repository from Github, and now I want to be able to upload my changes to a private repo so that a few other people can work on the changes with me. Unfortunately, since I cloned it instead of making a fork, so Xcode is trying to make the commits to the original repo. Is there a way to change what repo the commits are being made to? If there is, would there be a way to change it to a repo on another website (Bit Bucket)?

我从 Github 克隆了一个废弃的存储库,现在我希望能够将我的更改上传到私有存储库,以便其他一些人可以与我一起处理更改。不幸的是,由于我克隆了它而不是创建一个 fork,所以 Xcode 正在尝试对原始 repo 进行提交。有没有办法改变提交的repo?如果有,是否有办法将其更改为另一个网站(Bit Bucket)上的存储库?

I fully intend to make the repo public once the changes are complete.

我完全打算在更改完成后将 repo 公开。

回答by Blue_Alien

You can do it through UI

你可以通过 UI 做到

Select Source Control Navigator from the left pane

从左窗格中选择 Source Control Navigator

There you can find your current remote repo under the Remotes Folder,

在那里你可以在 Remotes 文件夹下找到你当前的远程仓库,

select Current Remote

选择当前遥控器

then delete the existing repo:

然后删除现有的回购:

Delete Existing Repo

删除现有仓库

Now You can add Your Existing Remote

现在您可以添加您现有的遥控器

Add New Remote

添加新遥控器

Enter Remote URL

输入远程 URL

Enter Git Remote URL

输入 Git 远程 URL

回答by VonC

As mentioned in "Git XCode - change origin", you simply can change the remote originurl, using git remote set-url(or in your case, rename+add).

正如“ Git XCode - changeorigin”中所述,您只需origin使用git remote set-url(或在您的情况下,重命名+添加)即可更改远程网址。

git remote rename origin upstream
git remote add origin /url/of/private/repo

(with the XCode GUI, you could remove, then add again, the remote origin)

(使用 XCode GUI,您可以删除,然后再次添加遥控器origin

If that private repo is empty, you can push to the full history of your cloned repo.

如果该私有存储库为空,您可以推送到克隆存储库的完整历史记录。

By renaming 'origin' to 'upstream', you keep the possibility to fetch from the original repo, while pushing to your new origintarget repo.

通过将 ' origin'重命名为 ' upstream',您可以保留从原始存储库中获取的可能性,同时推送到新的origin目标存储库。