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 ?
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.
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:
git rebase -i HEAD~6
(6 being the number of commits to rewind)Squash
to merge the commits togethergit push --force origin master
to force the history rewrite on the remoteNote: 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.
If your Team Project is configured using TFVC, then the process is slightly different.
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. 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.