Ignore certain changes for git commit

Members of our team uses different version of visual studio, and VS seems to automatically update the sln file with code like:

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual C# Express 2010


  • Visual Studo: Cant build/rebuild/clean after git merge
  • Handle multiple components in one or several Git repos?
  • NuGet issues with packages.config, project references and the solutionwide packages folder
  • .NET: Large revision numbers in AssemblyVersionAttribute
  • In Git, removing DLL and PDB files that have accidently been committed
  • How to get branches using LibGit2Sharp?
  • Microsoft Visual Studio Solution File, Format Version 12.00
    # Visual Studio 2012

    whenever we work with the solution. Can we configure git to ignore such changes? We’re not interested in this line, but we are interested in other changes of the .sln file, e.g. adding of new csproj to the solution.

  • Git push commits from another repo without the original user info
  • added new files during git interactive rebase, aborted rebase, new files missing
  • How to retain commit gpg-signature after interactive rebase squashing?
  • Reuse a Part of a git Repository
  • How to “pull” from a local branch into another one?
  • Can I merge/sync a sub-folder from one branch to the root of another in git?
  • 4 Solutions collect form web for “Ignore certain changes for git commit”

    It’s not possible to partially ignore a file. A simple solution would be to create two versions of the .sln file, and tell the team to open the one corresponding to their version.

    Another solution would be a post-commit hook that rejects the commit if these lines are changed. Needs a bit of scripting, but it’s feasible.

    On your local side you can simply update git index to ignore changes in certain file like this:

    git update-index --assume-unchanged SolutionFile.sln

    The same thing can do any of your developers.
    Another solution would be adding the file to .gitignore if you don’t want to keep it under source control.

    I would just ignore the .sln files for they are not relevant to building a project: Microsoft realized some time ago that project files must be versionable and novadays all building done by the Studio is carried out by msbuild engine which takes those .proj (and other .<whatever>proj, like .csproj, .vbproj etc) XML files and uses them to build a project. Those files is actually everything which is needed to build a project, and the solution file just contains various bookkeeping information.

    You can add a smudge/clean filter to git which calls a script to tweak the particular line to be consistent when committing. In “Can git automatically switch between spaces and tabs?”, it shows how to implement a similar change, where spaces are converted to tabs on checkout, and back to spaces on commit.

    You’ll probably need to write the script to identify and modify the relevant line, whereas the linked example uses pre-existing unix commands for swapping between tabs and spaces.

    Git Baby is a git and github fan, let's start git clone.