KevEllis
KevEllis

Reputation: 143

How can I have git ignore local changes to a specific file, without modifying the .gitignore?

My specific situation is this: I am working with a team on a git repo. We are using a vagrant machine, so in the git repo there is a Vagrantfile. I would like to modify my vagrant machine's configuration file to use specific amounts of memory and CPU cores, but i don't want to force all the other users of this repo to have these modifications. We DO want to have this Vagrantfile in the repo, so i can't add it to the .gitignore. I don't want to have to keep undoing and redoing my edits every time i commit my changes.

Upvotes: 3

Views: 667

Answers (3)

Jim Fell
Jim Fell

Reputation: 14254

This is an architecture issue, not easily addressed by Git itself. In my team we have addressed similar issues by having each developer maintain their own cloned copies of Git repos on shared computers, where...

C:\GitRepos\<developer>\

...would be each developer's Git working directory on the shared asset, and...

C:\GitRepos\<developer>\<repo>

...would be where each repo folder for each developer would be located. In this way, anything that needs to be specific to a developer, but not included in the repo, can be saved at C:\GitRepos\<developer>\. I hope this helps. :)

Upvotes: 0

JBarberU
JBarberU

Reputation: 1029

You could add it to your own $HOME/.gitignore file, unfortunately I don't think that affects files that are already version controled by git.

I usually do <some_file>_example and ignore <some_file>, which might be an option in your case.

Upvotes: 1

Monkey
Monkey

Reputation: 121

You can try git update-index --assume-unchanged <file>. This will assume that there is no change on this file, so it wont push it.

If you want to track it again, use git update-index --no-assume-unchanged <file>

Upvotes: 4

Related Questions