3

There are some local files (that are part of our repository) in a rails app that I would like git to ignore. Basically, I'd like git to ignore all changes I make to anything in the config/environments directory and to the config/application.rb file. I don't want to use .gitignore because I don't want OTHER people working on the code base to have their configurations ignored by git. Basically I'm doing a lot of testing that modifies the config files and sometimes my config changes are checked into a github which at a minimum is embarassing and at worst causes issues with the production environment.

What's the best approach here?

Ramy
  • 20,541
  • 41
  • 103
  • 153
  • check for the .gitignore file.If not just create a file .gitignore and mention the list of files you want to ignore like this config/database.yml /config/*.yml # Ignore all logfiles and tempfiles. /log/*.log /tmp – Thillai Narayanan Jan 20 '12 at 18:10
  • possible duplicate of [Committing Machine Specific Configuration Files](http://stackoverflow.com/questions/1396617/committing-machine-specific-configuration-files) – Senseful Sep 03 '14 at 19:35

4 Answers4

3

You can set up a global .gitignore.

Although, it will still see changes in files that already are in the repository. Here's how you work around this. You can probably make a bash macro out of it.

Sergio Tulentsev
  • 226,338
  • 43
  • 373
  • 367
2

You can do git update-index --assume-unchanged config/application.rb and git will not notice any changes you make to the local copy of that file unless you explicitly use git add.

My understanding is that .gitignore and friends won't change how files that are already put into the repository are handled, only whether untracked files are presented as candidates.

araqnid
  • 127,052
  • 24
  • 157
  • 134
0

You can define a global .gitignore that would be your machine specific, not checked into project repository.

Toms Mikoss
  • 9,097
  • 10
  • 29
  • 41
0

check for the .gitignore file.If not just create a file .gitignore and mention the list of files you want to ignore like this config/database.yml

 /config/*.yml
/log/*.log /tmp
Thillai Narayanan
  • 4,766
  • 5
  • 32
  • 39