0

I have a config file that contains settings of our project for my local machine, so i shouldn't push this config on remote, but should track changes of it's structure from remote (i guess i would merge that changes to my config when the time comes). So my options are:

  1. Add it to ignore, but it modifies a .gitignore file and i can't push it to remote because everyone should track changes.
  2. Add it to exclude file. I did. And SourceTree still shows it as modified!
  3. Just let the file be modified. Sore on an eye and i risk accidentally commit it somewhere.

I really like 2nd solution, but it doesn't work!

  • Q1: Am i wrong somewhere?
  • Q2: Why SourceTree works that way?
Archont
  • 101
  • 1
  • 9
  • Have you already pushed this config file to the remote? If so, adding it to `.gitignore` won't do anything. If you _haven't_ pushed the config file, then just ignore it locally. – Tim Biegeleisen Jan 19 '17 at 10:47
  • 1
    Q1: yes. It's not clear from the question where you think the `exclude` file is located; you wrote `.git/exclude` but it it located in `.git/info/exclude`. Second, only `git add` reads the exclude files. All the other commands use the repository information to know what files to check for modifications and so on. If you already committed the config file in the repo, just adding its name to the ignore files doesn't help. You also have to `git rm --cached` it and commit in order to tell Git to stop tracking it. Q2: SourceTree is just a wrapper. It runs Git to get the data. Go back to Q1. – axiac Jan 19 '17 at 10:53
  • @axiac, Thanks for answer. File located at .git/info/exclude as it should (that was an error in question naming). I'm a bit confused, let me describe situation as clear as possible: Remote repo has config. I cloned this remote repo. I changed config. I want still to track new changes in remote for this config, but remove my modified config from SourceTree screen, because i won't change it until remote's config is changed. I'm not advanced with Git Bash for now, so any further advice will be great! Thanks. – Archont Jan 19 '17 at 12:24
  • As far as i understand: "git rm --cached" removes file from tracking and if i merge for push i should discard this removal and i would back to the problem... – Archont Jan 19 '17 at 12:35
  • 1
    You either want the config file to be tracked (in this case there is nothing to change) or you don't want it (and you should add it to one ignore file and removed it from the repo). There is no middle way. Once the file is in the repo its changes are tracked and there is no way to prevent it (that would defeat the purpose of a VCS, isn't it?) There is a different (more or less standard) way to handle the config files in VCSes: put a template of the file in the VCS and add the actual file to the ignore list. Watch the changes of the template in repo and manually apply them to the real file. – axiac Jan 19 '17 at 12:46
  • @axiac, solid point. Thanks, i'll stop at your last suggestion. – Archont Jan 20 '17 at 07:10

0 Answers0