David Berg David Berg - 1 month ago 10
Git Question

Is it possible to see if a forced push was done on a git enabled tfs repository?

Is it possible to see if a forced push was done on a git enabled tfs repository?

In the tfs UI under "history" there are two options, "commits" and "branch updates". Under "branch updates" I think you see all pushes that have been done to the repository. In one of those I can see that a number of commits has been deleted, and the deleted commits is not visible in the tab where you see the commit history. Does this mean that this push was forced or is it any other way to delete commits (already pushed to the repository) without reverting them and make a new commit?

Answer

No there is no this option and "tag" to see this. And also there is not any other way to delete commits without reverting them and make a new commit. If you can see a number of commits has been deleted which just means the history has been rewrite and force pushed.

In TFS,rewrite or destroy history are also using rebase,squash command and need (force push) permissions for a branch. Detail steps 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.
  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

More details please refer this link from MSDN: Apply changes with rebase and this similar question Remove intermediate commit in Visual Studio Online