Git ignore particular files
Maybe an example will help. Here is a section of my .gitignore
file that is also part of the project files:
# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~
*.pro.user.*
tmp/
release/
debug/
bin/
moc_*
ui_*
*.bck
*_debug
#Visual Studio stuff
lib/*.lib
*.ncb
*.suo
This is just a part of the file. You'll need to tune yours depending on your project.
The point is that the format is flexible and you should not have issues sharing the file. If you have issues, exclude it from the repository.
If you want to ignore file config.local
in your repository, you just create a .gitignore
file with /config.local
line in it, add it and commit to the repository. That's it.
.gitignore is for files/folders that you haven't checked in already. It's essentially a text file that you create in the repository and has a list of paths relative to the directory it was placed in, which Git will ignore. You can check-in the .gitignore file as part of the repository. you can find examples - at the end of this page
However if your file has already been checked in the repository then you can use:
git update-index --assume-unchanged file
which will tell Git to ignore any changes to that file made in the future. However this is a local configuration so you will have to do it on each machine you check out. You can revert it by doing:
git update-index --no-assume-unchanged file
Depending on what configuration that file contains it might be a good practice to have a skeleton/example config file in the repository - similar to what PHP guys do with config_example.php, which then is used by people to create config.php, which in turn never get's checked in the repository because it is ignored.