在Visual Studio Online中删除中间提交 [英] Remove intermediate commit in Visual Studio Online

查看:141
本文介绍了在Visual Studio Online中删除中间提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我多次编辑了我的README.md,因为我没有看到预览按钮。



我可以删除它们中的一些,或者至少隐藏它们吗?

解决方案

小心



历史重写可以让你的源代码控制系统处于一个相当混乱的状态。确保您有足够的资源备份以防发生任何错误。 >根据您的团队项目设置,Readme.md存储在Git存储库中,您可以绝对重写历史记录并强制将压扁的提交推回到TFS,实质上使它忘记了中间数据。这是通过使用 git rebase 完成的,无法通过Visual Studio Online站点或Visual Studio Tools for Git完成。你需要从命令行执行它。



整个过程是在Git-SCM wiki中解释得很好。您需要执行以下步骤:


  1. 强制推送权限克隆包含readme.md的存储库。

  2. 使用 git rebase -i HEAD〜6 (6是提交回放的次数)

  3. 使用壁球
    合并提交
  4. li>使用 git push --force origin master 强制远程重写历史记录

注意:这将更改提交的散列和每个提交后的散列。做完这些之后,要么提醒所有其他贡献者重新同步,要么在进行这些提交后确保没有其他人在回购中工作。


$ b

如果您的团队项目使用TFVC进行配置,则该过程稍有不同。


  1. 确保您有要保留的文件的副本。

  2. 使用 tf销毁源文件控制中的文件$ / Teamproject / readme.md ,如果需要,可以使用 / keephistory / stopat:C12345 选项可销毁文件历史记录末尾特定变更集中的数据。

  3. 现在将您的备份文件复制回原位

  4. ,然后按照您通常的方式或从命令行 tf添加$ / teamproject / reqadme.md ,然后添加 tf checkin 。如果你保持了历史,TFVC将重新连接它。如果您完全摧毁了历史记录,TFVC将只添加一个新文件。


I edited my README.md multiple times because I didn't see the preview button. Now my commit history is full of useless commits.

Can I remove some of them, or at least hide them ?

解决方案

CAUTION

History rewriting can get your source control system in a pretty messed up state. Make sure you have a good backup of your sources in case anything goes wrong.

Git

Depending on your Team Project setup, the Readme.md is stored in a Git repository you can absolutely rewrite history and force push the squashed commits back to TFS, essentially making it forget the in-between data. This is done using git rebase and cannot be done through the Visual Studio Online site nor through the Visual Studio Tools for Git. You will need to do it from the commandline.

The whole process is explained very well in the Git-SCM wiki. You'll need to do the following steps:

  1. From an account with Force Push permissions clone your repository containing the readme.md.
  2. use git rebase -i HEAD~6 (6 being the number of commits to rewind)
  3. use Squash to merge the commits together
  4. use git push --force origin master to force the history rewrite on the remote

Note: this will change the hash of the commit and every commit that came after. After doing this, either warn all other contributors to resync or be sure that no others have worked on the repo after you made these commits.

TFVC

If your Team Project is configured using TFVC, then the process is slightly different.

  1. Make sure you have a copy of the file you want to keep.
  2. Destroy the file in source control using tf destroy $/Teamproject/readme.md, If need be you can use the /keephistory /stopat:C12345 option to destroy the data in specific change sets at the end of a file's history.
  3. Now copy your backed-up file back into place
  4. and check it in as you'd usually do or from the commandline tf add $/teamproject/reqadme.md followed by tf checkin. If you kept history around, TFVC will reconnect it. If you completely destroyed the history, TFVC will just add a new file.

这篇关于在Visual Studio Online中删除中间提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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