Reputation: 3215
I have a web project the root of which is the root of my git repo. Git is tracking most of the files in this project and pushing to a remote repo. At the root of the project I have a web.config file which I would like to track locally but not push to our remote repo.
Is this even possible with git?
Upvotes: 2
Views: 339
Reputation: 6258
VonC's answer is theoretically the best, assuming you can find a tool that can do the job for you based on the git repo of your flavor.
Mohamed is on to something, but didn't quite get there.
I copied the best bet from nasirkhan on this question
After your file is production-ready, e.g.: Web.config, run this command:
git update-index --assume-unchanged Web.config
If you need to update the web config again (Track Changes), run this:
git update-index --no-assume-unchanged Web.config
git-update-index documentation
Upvotes: 0
Reputation: 2252
This is possible, just create a file in the root of your project, and name it .gitignore
(don't forget the Dot (.
) in front of the file name). Then edit the file and paste whatever file you want to be ignored, for example, I like to ignore all files that have .ini extensions, so my .gitignore
looks like :
<<<<<<< HEAD
# built application files
*.ini
>>>>>>>
Upvotes: 1
Reputation: 19475
You could create a separate branch (I'll call it config
) and add your file there and use that branch to track changes to that file, merging in changes from your another branch (likely master
). You would then be free to push changes to the master
branch without needing to push the config file. But you would need to be careful to avoid pushing from the wrong branch.
Another option might be to commit changes to the config file in a separate repository, and have a symlink or copy in the working tree for your current repository. Adding that to the .gitignore file would prevent git in the current repository from listing that as something to be added. This way would be less likely to result in accidentally pushing that file to your server.
Upvotes: 0
Reputation: 1326376
One way would be to add a virtual reference with Gitolite installed on the Git upstream repo side (the one you are pushing to).
That kind of update hook can analyze the content of the files which are push to and reject a push if it contains the wrong file.
The VREF FILETYPE is an example.
Upvotes: 2