Files on Visual Studio Team Services out of sync (Git repo)

Probably missing something really trivial here but struggling to figure a way out..

We have a Git repository setup on Visual Studio Team Services. Since 1st February, several files seem to have gone out-of-sync with their history of commits. Their history contains loads of recent changes, but when pulling the latest version, we actually get old copies.

It is not clear if anyone in the team might have accidentally issued weird commands on the remote repository.

What is quite clear though, is that the "current" remote versions visible via the VSTS web portal seem to be older than what they should be according to their history (so not an issue with just local repos).

Below is just one example:

Current version

Changes history

Latest commit

Even though the last commit shows a few new lines were added, the 'current version' of the file doesn't contain them.. And there are no further commits in the history!

Any suggestions on how to verify what is happening to the remote repo and fix it, or whether this is a known issue on VSTS (they have been having problems recently and the service was down yesterday..)

Answers


This is most likely due to a botched merge. What probably happened is that someone did a pull, got some conflicts, resolved said conflicts, then noticed before committing the merge that he had a bunch of staged changes that were not his (and not related to the conflicts in any way). He figures this is a weird git bug or something, and discards those changes, then commits. Those discarded changes are the ones you are missing; they should have been committed with that merge. The reason why you do not see this "undoing" commit in the history for the file is that, by default, git (and other tools) do not show merge commits in file histories unless the file is different than both of the merge parents. If you do a git log <filename> --full-history, you should see the merge commit that reverted the file to an older version. Moral of the story: when committing a merge, commit ALL staged changes, even if (or especially if) you did not make them.

EDIT: One dangerous thing about botched merges is that they can happen without somebody noticing for quite a while, especially since they don't show up in the default git log of the file(s) whose changes were lost. The following script will detect most botched merges, reporting which files have lost changes. It could be tweaked to be used as a commit hook, to only check certain commits, etc. It works by seeing if there are any files reverted by the merge to the state they were at when the two branches last diverged.

Note that I am a total newbie when it comes to shell scripting, so please forgive the poor code quality.

isChangeInBaseChanges() {
  for element in ${baseChanges[@]}; do 
    if [ $element == $change ]
      then 
      return 1
    fi 
  done
  return 0
} 


for merge in `git rev-list --min-parents=2 --all`; do
  mergeChanges=`git log -m -1 --name-only --pretty="format:" $merge | sort -u`
  mergeBase=`git merge-base $merge^ $merge^2`  
  baseChanges=`git diff --name-only $merge $mergeBase`

  lostFiles=()
  for change in ${mergeChanges[@]}; do
     isChangeInBaseChanges
     if [ $? -ne 1 ]
     then
       lostFiles+=($change)
     fi 
  done

  if [ ${#lostFiles[@]} -ne 0 ]
  then
    echo -n "Possible botched merge at "
    echo  $merge
    echo "files with lost changes are: "
    for lostFile in ${lostFiles[@]}; do
      echo $lostFile
    done
    echo --------------------------------------------
  fi

done

Need Your Help

Cross-Dissolve UIImage in UITableViewCell or UICollectionViewCell

ios core-animation calayer uiviewanimationtransition catransition

I have a UICollectionView that has Cells that contain ImageViews in them. After downloading the images that I want to display in the cell I'd like to cross-dissolve my image with the placeholder im...