Reputation: 1290
I want to be able to have two files change simultaneously in different projects.
I would like to use git to ONLY track content changes to my files, I do not care about so called typechange
changes. Can I change my git configuration or edit my .gitignore
file?
I have a file ~/proj/real_foo
that has identical contents to the tracked ./foo
but I want to be able to have both files change simultaneously in different projects.
> ls
foo
> git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
> rm foo; ln -s ~/proj/real_foo ./foo
> git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
typechange: foo
no changes added to commit (use "git add" and/or "git commit -a")
> ls
foo
> git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
> rm foo; ln -s ~/proj/real_foo ./foo
> git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
Upvotes: 1
Views: 2934
Reputation: 76964
Git doesn't provide a way to ignore type changes. This is a specific case of the more general case of ignoring changes to tracked files, to which the answer is, Git doesn't offer that as an option. Trying to use one of the git update-index
suggestions typically offered doesn't work, as the documentation states.
What you can do here is to ignore foo
and provide some template for it that's copied over by your build system or a script if it doesn't exist. Since a symlink exists, it will be preserved, while still making the code work on a fresh clone with a plain file. You could also have your build system or script just symlink to the template file instead.
Upvotes: 2