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

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


当前回答

我也遇到过同样的问题。

在我的例子中,由于我在本地机器中有原始的存储库,所以我在一个新文件夹中创建了一个副本,没有任何隐藏文件(。git, .gitignore)。

最后,我将.gitignore文件添加到新创建的文件夹中。

然后,我已经从本地路径创建并添加了新的存储库(在我的情况下使用GitHub Desktop)。

其他回答

要将你现有的回购变为不同的,你需要:

首先克隆原始的回购。 Git克隆https://git.fedorahosted.org/cgit/rhq/rhq.git 将克隆的源代码推到您的新存储库: cd rhq Git推送https://github.com/user/example master:master

您可以将master:master改为source:destination分支。


如果你想要推送特定的提交(分支),那么做:

On the original repo, create and checkout a new branch: git checkout -b new_branch Choose and reset to the point which you want to start with: git log # Find the interesting hash git reset 4b62bdc9087bf33cc01d0462bf16bbf396369c81 --hard Alternatively select the commit by git cherry-pick to append into existing HEAD. Then push to your new repo: git push https://github.com/user/example new_branch:master If you're rebasing, use -f for force push (not recommended). Run git reflog to see history of changes.

如果你有现有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

我做到这一点的方法是:

在github上创建一个新的repo (new-repo.git) CD old-repo/在本地机器上获取所有新的更改 Git push -u https://github.com/[username]/new-repo.git main -f 将新的远程repo https://github.com/[username]/new-repo.git克隆到本地环境

我发现这是一个简单的方法,基本上复制一个旧的远程回购到一个新的远程回购。

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

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