halidziya
halidziya

Reputation: 80

Git track only in local copy

I have a remote repository in a server location. I am keeping local copies in two machines. In the code, there are file paths that are machine specific. I would like to keep one local copy sync with the remote and another just ignore changes. Am I able to do that ? I can remove the file from versioning system, however, is there a better way to do that ?

Thanks

Upvotes: 0

Views: 64

Answers (2)

Gregg
Gregg

Reputation: 2624

use

git update-index --assume-unchanged MYLOCAL.CFG

so, that on commit, changes to the file will be ignored

but git pull origin

will complain that MYLOCAL.CFG is going to be changed so you have to manually save and restore.

copy MYLOCAL.CFG MYLOCAL_SAVE.CFG
git checkout -f MYLOCAL.CFG
git PULL 
copy MYLOCAL_SAVE.CFG MYLOCAL.CFG
git update-index --assume-unchanged MYLOCAL.CFG

Upvotes: 0

Keif Kraken
Keif Kraken

Reputation: 10670

You could use a user.config file which would include any of the file paths or machine specific variables which would overrid the web.config or other config files. Then you would add the user.config file to the .gitignore.

Upvotes: 1

Related Questions