2

Is there a way in git to prevent a file form being committed?

My use case is i have a config file which resides in master branch in remote location , when locally cloning it i require few local changes which are not to be pushed in master , can there be some configuration in remote or local branch which prevents this file from being be pushed.

This file can be changed through some moderator and i need to have latest copy of it in my local every time i do a git pull.

Which is the best way to go about it?

2 Answers2

0

Once cloned, you can type:

git update-index --assume-unchanged -- yourFile

None of the local modifications you will add to that file will be visible in git status.

For more on that command:http://fallengamer.livejournal.com/93321.html

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

Iif you want to track most of the changes upstream might make but not some specific ones, you can use filters to edit the file on checkout and checkin, applying your local changes on its way out of the repo and reversing them on its way back in -- here's an example of how to do it.

Community
  • 1
  • 1
jthill
  • 55,082
  • 5
  • 77
  • 137