Git存储库清理

时间:2018-03-30 05:59:07

标签: git repository bitbucket

所以我有这么大的bitbucket存储库,有很多分支,每个分支都有数十个提交,其中一些非常小。现在整个过程完美无缺,我想要一个只有最终提交和必需分支的干净仓库。如何实现清理库清理?我可以在哪里删除不必要的分支和提交,并有一个最终的清洁回购?

请帮帮我。

2 个答案:

答案 0 :(得分:0)

从解决方案here

# Make sure remotes are up to date (with stale remotes purged):
git fetch -p

# Initial no-op run --- do the branches to delete look correct?
# Be careful to omit 'master' from the output.
git branch --remote --merged origin/master | grep -v 'master' | cut -b 10- | xargs

# Do the bulk delete!!!  (can take a long time...)
git branch --remote --merged origin/master | grep -v 'master' | cut -b 10- | xargs git push --delete origin

这将删除已合并为' master'科。您可以修改以反映您的仓库使用的任何组织。

答案 1 :(得分:0)

  1. 首先从您的电脑中的bitbucket repo克隆最终提交。为此,请参阅此帖:https://coderwall.com/p/xyuoza/git-cloning-specific-commits

  2. 然后清除完整存储库而不删除repo本身。为此,请参阅此帖:Delete all files and history from remote Git repo without deleting repo itself

  3. 然后再次将最终副本(您之前从git repo克隆的副本)推送到您想要的bitbucket存储库。

  4. 如果我在这里写了一些不合适的东西,我很抱歉。我是新手。所以请不要介意。 我不知道你是否想要这样的解决方案! 如果不是那么我再次抱歉。