清除Git存储库 [英] Clear Git repository

查看:142
本文介绍了清除Git存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须将TFS服务器转移到GIT(Bitbucket)服务器.

I've to transfert a TFS server to a GIT(Bitbucket) server.

我们目前正在使用git-tfs进行此操作,但是在迁移之前我们正在做一些测试(例如配置jenkins,检查是否正确传输了所有内容).

We are currently using git-tfs to do it, but we are doing some tests before migrating(like configuring jenkins, checkin that everything is correctly transfered).

问题在于,现在看来我无法运行git push命令,因为我的存储库已经充满了上次运行中的很多内容.

The issue is that now it seems I cannot run the git push command because I've the repository that is already filled with a lot of stuff from the previous run.

是否有一种方法可以重置"存储库(例如,如果我从未执行过任何提交)?没有删除吗?

Is there a way to "reset" the repository(like if I've never done any commit) ? Without deleting it?

我发现了这个问题:在Bitbucket上清除git存储库?但是问题出在是我要花6年的时间,拥有60多个分支,所以我不能一一清理它们.

I've found this: Clear git repository on Bitbucket? but the issue is that I'm committing 6 years of work, with more than 60 branches, so I cannot just clean them one by one.

我也不能只删除存储库,我们已经配置了很多东西(钩子,与jenkins的连接,...).

I also cannot just delete the repository, we have already configured a lot of things(hooks, connections to jenkins, ...).

推荐答案

这确实取决于TFS版本/bitbucket.您可以删除所有分支和标签,然后将Master重置为第一次提交,以得到一个干净的状态.但是根据您的TFS服务器版本,这实际上可能不会导致垃圾"被收集.我不确定BitBucket上的垃圾回收策略.

This really depends on the TFS version/bitbucket. You could just delete all the branches and tags and reset Master to the very first commit to get a clean slate. But depending on your TFS server version this may actually not cause the "garbage" to be collected. I;m not sure about the garbage collection policies on BitBucket.

TFS 2015更新3中引入了Git垃圾收集,即使删除了所有引用,旧版本实际上也不会清理服务器上的任何内容.

Git garbage collection was introduced in TFS 2015 update 3 and older versions won't actually clean up anything on the server, even if you've deleted all references to it.

您可以轻松编写清理过程的脚本.使用git fetch --all确保本地存储库具有所有分支信息,然后使用git branch --list -r列出所有远程分支.这样,您可以轻松地脚本删除这些分支并将其删除推送到服务器.

You could easily script the cleanup process. use git fetch --all to make sure your local repo has all branch information, then use git branch --list -r to list all remote branches. With that you can easily script deleting these branches and pushing their deletion to the server.

然后使用git update-ref refs/heads/master a12d48e2 (插入您自己的提交)以重置母版.

Then use git update-ref refs/heads/master a12d48e2 (insert your own commitish) to reset the master.

然后git push --force --all将所有内容发送回服务器.

Then git push --force --all to send everything back to the server.

这篇关于清除Git存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆