Edit local files without committing

3

In a project there are some files that need editing to run the local server, such as .htaccess , config.php , among others.

In branch master , we keep these files with the data in production. There are some developers who have different settings for running a server locally, so each one works with different data in some files.

In this case, I would like to have some files set up for my local machine with no need to commit of them and not "clutter" the code of branch master in a possible merge .

.gitignore deletes these files in the repository. Is there any other solution? How is your method of working to solve this problem?

    
asked by anonymous 05.05.2015 / 21:43

2 answers

4

The standard / ideal is to tell git not to follow modifications of these files. This is done with the command:

git update-index --assume-unchanged <filename>

The file will continue to be part of the repository, but local changes will not be considered during the commit.

When you want git to go back to the changes, use the --no-assume-unchanged flag:

git update-index --no-assume-unchanged <filename>
    
06.05.2015 / 13:36
1

The ideal would be to create a directory where you would put the required files running and delete it with .gitignore .

For example, create a directory named build and when launching execution, move all files to this directory. Thus preserving the original data of the files, allowing them to be edited without creating the risk of being accidentally added to the commit.

    
06.05.2015 / 08:32