Matthew Flynn Matthew Flynn - 3 months ago 12
Git Question

Binary File Merge in GIT in Visual Studio 2013 Ultimate

We are using TFS with GIT for source control.

I am trying to pull the latest version but am having issue with dll files being out of sync.

I have done the following;

Tried to pull the latest commits from the team explorer menu. I then get the message;


An Error Occurred: 33 uncommitted changes would be overwritten by the merge


So I then ran another commit and included all excluded files. This included DLLs etc.I did this by going to the team explorer -> changes

Then added the 33 untracked files, and committed locally.

Next, I clicked sync and then pull from the incoming commits menu.

I then get the message;


Pull completed with conflicts. Resolve the conflicts and commit the results.


i click the 'Resolve the conflicts' link and it gives a list of 77 files (dlls csproj and pdb files). See the screenshot below;

team explorer on merge

However, when I click the keep local or keep remote link nothing happens.

If i select the merge button i get the message

git popup 2

Can someone direct me as to how to resolve this?

Answer

Git repositories do not handle binaries well. Git is optimized for text files, which it can effectively diff and compress. Binaries cannot be diffed and compressed, so they cause the repository to bloat -- Git has to store the entire binary every time you commit a new version of it. This causes the repo to become massive and slow to clone, as well as having a huge negative impact when switching branches.

The correct way to handle assembly references is to use a package manager to allow binaries to be restored at build time, not committed to source control. This also gives you additional flexibility around managing versions of assemblies.

For other types of binaries (such as images), Git LFS allows you to use effective blob storage for your binaries, while still keeping the repository lean and consisting only of easily-diffable/compressible text. TFS 2015 Update 2 supports Git LFS, but earlier versions do not.

That said, you definitely should set up a .gitignore file (if you don't have one already) to make sure your bin and obj folders are not in source control; they absolutely should not ever be in source control; it makes no sense. If you have a bunch of old commits polluting your history, you can remove them with a tool like BFG, but be aware that it rewrites the history of your Git repo, which may cause problems for other team members. It's something that you should do, but should be carefully coordinated with the rest of the team to make sure no one hits any problems.