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 ?
To do the same in Visual Studio, right-click the commit you want to revert and then select Revert. After you confirm your action and the operation is complete, Visual Studio displays a success message and a new commit appears in the Outgoing section.
To delete commits from remote, you can use the git reset command if your commits are consecutive from the top or an interactive rebase otherwise. After you delete the commits locally, push those changes to the remote using the git push command with the force option.
Removing the last commit To remove the last commit from git, you can simply run git reset --hard HEAD^ If you are removing multiple commits from the top, you can run git reset --hard HEAD~2 to remove the last two commits.
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 together
git 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.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With