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?
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:
repository
|
+-- configuration
+-- user-configuration
And team-shared configuration
like this:
default_values_shared_by_team
include_if_exists user-configuration
some_code
...
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.