How to manage locally modified versioned file without committing it to Git?

I have this annoying problem since I upgraded to Visual Studio to 2015.

There is a batch script in my repository to compile all sources, based on the Visual Studio version. Since I updated it but other users kept VS 2013, I had to change the Visual Studio version in order to compile sources, and now I’m forced to live with the modified script file that pops every time I commit anything.

I tried to stash it, but when I git stash pop my changes (that could happen daily) the modified script pops alongside other files.

So I was wondering, is there a way to tell Git to keep a file as it is for good?

  • Aborting a stash pop in Git
  • how to alias git checkout && git stash apply
  • No stash found when using git stash branch
  • How to recover from “git stash save --all”?
  • Can I influence the merge strategy used by “recursive” when applying a git stash?
  • Git - stash to branch - files in stash being re-applied to master
  • Git: How to recover stashed uncommitted changes
  • Alias: `git pop last`, for `git stash pop `
  • One Solution collect form web for “How to manage locally modified versioned file without committing it to Git?”

    What you’re doing is a broken workflow, that’s why you have problems.

    I suggest you to use a different workflow, it’s actually the same as Visual Studio uses (see bellow).

    Basically, you have a script shared by the whole team, but you also need to have a user-specific script. So change that team-shared script to include a user specific script (only if it exists) and commit the team-shared script.

    Then create the user-specific script which will overwrite or redefine the values from the team-shared script you need to change and add this user-specific script to .gitignore (and don’t commit it!).

    This way each member of your team can have his own user-specific configuration without messing with other members of his team. By the way, that’s exactly what Visual Studio is doing – *.sln is a shared solution configuration and *.suo is a user configuration, which shouldn’t be committed.

    Repository can look like this:

      +-- configuration
      +-- user-configuration

    And team-shared configuration like this:

    include_if_exists user-configuration

    In user-configuration you simply change default_values_shared_by_team to values you need to have on your setup. If user-configuration file doesn’t exist, nothing happens, everything works as before, so other team member are not affected.

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