0

I have a file that holds IP configs for my local machine. This file must remain unchanged from the hosted version in github. I am using Atlassian SourceTree to check my files in but the options available do not work for me.

right-click - Remove (this deletes the file from my root I think)

right-click - Discard (this reverts my changes)

right-click - Stop Tracking (this creates a gitignore with the file path. It can't be ignored. it just needs to stay unchanged but able to be pulled)

enter image description here

My root structure looks like this

  • .git (folder)
    • info (folder)
      • exclude (file)
  • bin
  • optimizer
  • src
    • main
      • webapp
        • frontend
          • config
            • webpack
              • Base.js
  • .gitignore
  • README.MD

My exclude file contains /src/main/webapp/frontend/config/webpack/Base.js

Does anyone have any solution to this? Other questions here proposed the exclude folder approach but it's not working for me. AS you can see in the image the Base.js file is still in the Unstaged stack.

Thanks in advance

LOTUSMS
  • 10,317
  • 15
  • 71
  • 140
  • The fact that git shows a *diff* for the file means it is already tracking the file. `.gitignore` is only used during `git add` and its siblings, if you've managed to already track a file, git is tracking that file. If you now ask git to remove that file, you will delete that file on your machine as well as anyone that pulls from that repository. This is a well known "problem" and is usually solved by not keeping local config files in git at all in any form, but instead keeping template files tracked and the local config files ignored. – Lasse V. Karlsen Feb 21 '18 at 14:45
  • There are plenty of tutorials and articles out on the web for this and there should be quite a few questions here on Stack Overflow already. Voting to close as a duplicate of one of them. – Lasse V. Karlsen Feb 21 '18 at 14:46
  • Possible duplicate of [ignoring local config files in git](https://stackoverflow.com/questions/8943936/ignoring-local-config-files-in-git) – Lasse V. Karlsen Feb 21 '18 at 14:46

1 Answers1

1

Although not through SourceTree, you can run the following command locally to achieve this

git update-index --assume-unchanged /src/main/webapp/frontend/config/webpack/Base.js
user6123723
  • 10,546
  • 18
  • 67
  • 109