假设我在git.fedorahosted.org上有一个存储库,我想将其克隆到我在github的帐户中,以拥有自己的游乐场,而不是在fedorahosted上更“官方”的回购。 最初复制的步骤是什么? 在github中有一个漂亮的“fork”按钮,但我不能使用这个明显的原因。

我如何跟踪fedorahosting回购到github的变化?


当前回答

如果你有现有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的repo URL,简单地指向新的repo:

git remote set-url origin [new repo URL]

例如:git remote set-url origin git@bitbucket.org:Batman/batmanRepoName.git

现在,推和拉与新的回购挂钩。

然后像这样正常地推:

git push -u origin master

这是帮助我推动我的本地项目到一个不同的回购git

 git push https://github.com/yourusername/yourgithubproject.git master:master

Visual studio 2022和默认的git扩展甚至不需要一行命令就可以完美地工作。

步骤1:进入git设置

步骤2:在git/azure中添加指向不同存储库的新原点

步骤3:现在你可以选择在git/azure的不同存储库中推送到新的原点

现在在新的存储库中有了一个新的分支

我用set-url找到了一个简洁易懂的解决方案:

在Github创建一个新的回购 CD到本地机器上现有的存储库中(如果您还没有克隆它,那么请先执行此操作) Git远程set-url origin https://github.com/user/example.git Git push -u origin master

下面是手动执行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

你也可以同时使用两个/多个遥控器。