Thursday, February 2, 2017

Fixing Merge conflicts in VS Code projects and VSTS (Visual Studio Online) repos

I use a combination of GitHub and Visual Studio Team Services (Visual Studio Online, VSTS, etc) repositories. GitHub is pretty straight forward for resolving merge conflicts of pull requests through it's online portal. Typically when I have come across merge conflicts in my VSTS repositories it has been with Visual Studio projects and so I could resolve them with the VS GUI. However I recently experienced a merge conflict with a pull request for one of my VSTS repositories where the code was written in Visual Studio Code. For working with the VSTS GIT repo I use the posh-git which comes with the GitHub Desktop install, but the logic here should transfer.

The situation I faced was that I had been working in a branch and editing a file, which had also been edited by a colleague in the master branch (I know, I know...). So when I pushed my changes from my local repo to VSTS and then used the web portal to create a Pull Request to merge the changes back into the master branch I received an error that there was a merge conflict blocking the pull request.

As I mentioned normally in this situation I am use to there being options provided to select which file/change you want to be kept. In VSTS i was not able to find any such option, and all articles online seemed to indicate how to fix this in Visual Studio GUI. While I do have VS installed I didn't want to use that as I am trying to just move to using VS Code and GIT command line where possible. I never did think to try the git menus in VS Code, or the GIT GUI..... and to be honest there is probably a better way to resolve this but this is how I resolved the conflict.

First I abandoned the Pull Request using the button in the screen shot above.

Next I ran git status to make sure that the "working tree is clean"

Then by looking at the history of the file in the VSTS portal within my branch, I tracked down the original commit id that the file was initialised with. Taking that identifier I ran git reset InitialCommitId PathToFile (e.g. git reset e99a################################c60 XML\9.xml

Now when you run git status it should so the file is unstaged. It will also show that there are changes for the same file to be committed. We need to discard the changes in the working directory (resetting it to the initial version the branch was created from). So run git checkout -- XML\9.xml

Now git status should show a change to be committed. Commit the change with git commit -m "description"

Your working directory should now show it is ahead of the origin branch, so push the changes upstream with git push.

Now your branch in VSTS does not contain any conflicts. I wasn't able to reactivate the existing pull request and have it succeed (it still showed the conflict), so I created a new fresh pull request for the branch and it was no longer blocked by a merge conflict.

Hopefully this helps others. If you have other suggestions on working around this please comment below.

Legal Stuff: The contents of this blog is provided “as-is”. The information, opinions and views expressed are those of the author and do not necessarily state or reflect those of any other company with affiliation to the products discussed. This includes any URLs or Tools. The author does not accept any responsibility from the use of the information or tools mentioned within this blog, and recommends adequate evaluation against your own requirements to measure suitability.


  1. Høj kvalitet bedste ur til salg af en pålidelig urmager? Her kan du tilbyde det bedste replika Omega urei høj kvalitet, herunder Cartier, Breitling osv.

  2. Late in the 19th century it was pocket and chatelaine watches that were most popular, but Louis replica Cartier watches saw a future in timepieces that could be worn on the wrist.Invest in an heirloom to cherish forever with a timepiece from the replica Ballon Bleu de Cartier watches watch collection.A fusion of cutting-edge technology and heritage craftsmanship, Cartier’s fine watches carry the prestige of the brand’s illustrious history and exceptional quality.

  3. OMEGA has been a world leader in advanced watch design since 1848. Over the years, cheap replica watchesthe brand has been widely celebrated for their durability and precision. replica omega watches has served as the official timekeepers of the Olympic Games for nearly a century. They also created the official watch of the space program and first watch to land on the moon. Buying an OMEGA watch is an excellent way to invest in a piece of history.

  4. International Watch Company, or IWC, was first introduced to the world in 1868 when an American Engineer,replica watches sale Florentine Ariosto Jones, decided to open his own factory in Switzerland. replica IWC watches has earned its reputation as one of the world's finest manufacturers of Swiss luxury watches. IWC only manufactures automatic and manual timepieces which include features such as the chronograph and GMT dual time zone. IWC has definitely made its mark in the world of watches with its dedication to excellence in form and function. Using a range of supplies a large selection of IWC watches at the best sale prices online so buy yours today!

  5. Cartier has recommended many classic and successful watch collections, such as fake cartier watches, Cartier Santos and Cartier Ronde and so on. Every Cartier watch has its special charm, and Cartier watches are many people's dreams. Our replica santos dumont watchesshop provides different Cartier replica watches at very low prices. Just enjoy shopping here.

  6. Buy a discounted replica watches uk IWC watch from this Time and get free shipping. replica iwc watches Large selection in stock. IWC watches, is an iconic brand. The IWC Portuguese, a collection that includes the IWC Portuguese automatic and IWC Yacht Club chronograph is legendary. IWC Schaffhausen is also known for the IWC Aquatimer, Top Gun, Big Pilot watch, Mark XVII, Pilot's Watch, Spitfire chronograph and their Big Pilot Watch, the St-Exupery.

  7. replica breitling watches is one of the world's most respected Swiss horologists. Founded in 1884 in Saint-Imier, the brand cemented its reputation as an aviation specialist, but miniforwatchis now an authority in diving and chronograph categories, too. Specialist watchmaking All COSC certified chronometers.

  8. cheap Soccer Jerseys is the best soccer jerseys wholesale xavi hernandez Jerseys Buy the cheap soccer jerseys, soccer shirts, soccer kits, training kits with wholesale price.

  9. La marque avec le motif emblématique du crane McQueen, réplique de alexander mcqueen y compris des pas cher homme alexander mcqueen foulards et une variété de produits avec des sacs à boucles, repousse les limites de la culture, de l'art et de la mode. En été, les entra?neurs surdimensionnés pour hommes et femmes continuent d'être les livres les plus vendus.

  10. Rolex watches are crafted from the finest raw materials and assembled with scrupulous attention to detail. cheap replica watchesEvery component is designed, replica rolex watchesdeveloped and produced in-house to the most exacting standards.