假设我在git.fedorahosted.org上有一个存储库,我想将其克隆到我在github的帐户中,以拥有自己的游乐场,而不是在fedorahosted上更“官方”的回购。 最初复制的步骤是什么? 在github中有一个漂亮的“fork”按钮,但我不能使用这个明显的原因。
我如何跟踪fedorahosting回购到github的变化?
假设我在git.fedorahosted.org上有一个存储库,我想将其克隆到我在github的帐户中,以拥有自己的游乐场,而不是在fedorahosted上更“官方”的回购。 最初复制的步骤是什么? 在github中有一个漂亮的“fork”按钮,但我不能使用这个明显的原因。
我如何跟踪fedorahosting回购到github的变化?
当前回答
下面是手动执行git remote set-url origin[新回购URL]的方法:
Clone the repository: git clone <old remote> Create a GitHub repository Open <repository>/.git/config $ git config -e [core] repositoryformatversion = 0 filemode = false bare = false logallrefupdates = true symlinks = false ignorecase = true [remote "origin"] url = <old remote> fetch = +refs/heads/*:refs/remotes/origin/* [branch "master"] remote = origin merge = refs/heads/master and change the remote (the url option) [remote "origin"] url = <new remote> fetch = +refs/heads/*:refs/remotes/origin/* Push the repository to GitHub: git push
你也可以同时使用两个/多个遥控器。
其他回答
这是帮助我推动我的本地项目到一个不同的回购git
git push https://github.com/yourusername/yourgithubproject.git master:master
您真的想简单地将本地存储库(及其本地分支等)推到新的远程,还是真的想在新的远程上镜像旧的远程(及其所有分支、标记等)?如果是后者,这里有一个关于如何正确镜像git存储库的很棒的博客。
我强烈建议你阅读这篇博客,了解一些非常重要的细节,但简短的版本是这样的:
在一个新目录下运行这些命令:
git clone --mirror git@example.com/upstream-repository.git
cd upstream-repository.git
git push --mirror git@example.com/new-location.git
在github创建一个新的回购。 将repo从fedorahosted复制到本地机器。 Git远程重命名上游源 git远程添加源URL_TO_GITHUB_REPO Git push origin master
现在你可以使用它就像任何其他github回购。要从上游导入补丁,只需运行git pull upstream master && git push origin master。
如果你有现有Git存储库:
cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab.com/newproject
git push -u origin --all
git push -u origin --tags
从命令行推现有存储库
git remote add origin https://github.com/AyadiAkrem/teachandgo.git
git branch -M main
git push -u origin main