0

I have a file "src/data/sensitive-data.json" that contains contents:

{ "appInstanceKey": "<Virtual App Key Here>", "email": "<Email Here>", "password": "<Password Here>" } 

I pushed that to my repo.

I now added to my .gitignore

src/data/sensitive-data.json 

and then pushed that to my repo in a separate commit.

I want to now change my sensitive-data.json to actual credentials so i make the change and tell git to stop tracking with SourceTree (i believe it's using git rm -r --cached) and push that.

The problem is when someone new pulls the repo, the data folder and the sensitive-data.json file don't exist at all. I want it to exist with the original contents, but I want to be able to change the data locally without it being tracked.

What step did I mess up or what am I missing to accomplish this? I looked at other SO answers and I feel like i'm following them correctly.

Thank you

9
  • Does this answer your question? How to stop tracking and ignore changes to a file in Git? Commented Feb 3, 2020 at 20:57
  • @JeffMercado there's ALOT of information on that thread that seems to be misleading.. i'm still trying to sort through it but that's why i created this one Commented Feb 3, 2020 at 21:36
  • My understanding is you basically have a file that contains configuration data. By default, you want it to have certain settings, but for your own local development, you want to change the values and not accidentally commit those changes. In this case you could --assume-unchanged or --skip-worktree. Commented Feb 3, 2020 at 21:40
  • 1
    --skip-worktree might be the best option. stackoverflow.com/a/13631525 Commented Feb 3, 2020 at 21:48
  • 1
    Does this answer your question? GIT - How to remove local file from tracking, but leave copy on remote repository? Commented Feb 3, 2020 at 22:04

1 Answer 1

2

There is a great article on github about removing sensitive data from repository, but maybe you should consider having structure like this:

/src/data/sensitive-data.json <-- This is not tracked by git at all /src/data/sensitive-data.json.example <-- This is tracked by git 

Having structure like that ensures that future code users will know how the file should be looking and it is pretty safe for you to not include sensitive data in your repository.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.