拥有干净历史的fork git repo - 会推动工作吗?

时间:2015-10-01 15:15:44

标签: git

我想把一个从github到repbucket的repo用干净的历史(我不需要,我想节省空间)。我发现我可以用git clone --depth 1(浅层克隆)做到这一点,但我的问题是我是否能够将更新从原始仓库推送到新仓库?

1 个答案:

答案 0 :(得分:1)

我最终决定在没有git clone --depth 1的情况下使用其他解决方案 - 我无法将浅层克隆推送到github上的新repo。我明白我使用了错误的方法。

我创建了一个没有提交历史记录的新分支,如下所示:Make the current commit the only (initial) commit in a Git repository?

git branch new_branch_name $(echo "commit message" | git commit-tree HEAD^{tree})

然后我按照这篇优秀指南中所述将其推送到新的回购:How to fork a github repository in bitbucket

$ git checkout new_branch_name
$ git remote add bb git@bitbucket.org:jcaraballo/test.git
$ git push -u bb new_branch_name

所以现在我在新仓库中只有一个分支,其中包含干净的历史记录,我可以通过分支new_branch_name在回购之间交换更新,并在那里合并更改。