Remove intermediate commit in Visual Studio Online

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

Is it possible to remove some of them, or at least hide them?

+3


source to share


1 answer


Attention

Rewriting history can leave your source control system in a rather confusing state. Make sure you have a good backup of your sources in case something goes wrong.

Git

Depending on the Team Project setup, Readme.md is stored in a Git repository, which you can completely rewrite in history and force push to the distribution back to TFS, which essentially makes it forget intermediate data. This is done using git rebase

and cannot be done using the Visual Studio Online site or using the Visual Studio Tools for Git. You will need to do this from the command line.

The whole process is explained very well in the Git-SCM wiki . You will need to follow these steps:



  • From an account with Force Push permissions, clone your repository containing readme.md.
  • use git rebase -i HEAD~6

    (6 - number of fixations to rewind)
  • use Squash

    to merge commits together
  • use git push --force origin master

    to rewrite history on a remote computer.

Note : This will change the hash of the commit and any commits made after it. After that, either warn all other contributors to re-sync, or make sure no one else has been working on the repo after these commits have been committed.

TFVC

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

  • Make sure you have a copy of the file you want to keep.
  • Destroy the file in the original control with tf destroy $/Teamproject/readme.md

    . If needed, you can use the option /keephistory /stopat:C12345

    to destroy data in specific changesets at the end of the file history.
  • Now copy the backup file back into place
  • and test it as usual or from the command line tf add $/teamproject/reqadme.md

    and then tf checkin

    . If you've saved history around, TFVC will reconnect. If you've completely destroyed history, TFVC will simply add a new file.
+7


source







All Articles