0

I had to modify application.xml to deploy the application locally, and this change shouldn't be pushed to repository. Now the problem is, this change is always present in Changes not staged for commit and I couldn't use use git add . when committing changes.

One solution would be to add this file to .gitignore, but this just replicates the same problem to target .gitignore file, as application.xml shouldn't be ignored globally.

I tried also to add it to exclude file, but it didn't seem to work, probably because file is already tracked.

Does git provide some convenient tool to handle situations like this. It should be also possible to be able to switch branches retaining those locally untracked changes, and still pull latest version of this file if someone else changed it.

Tuomas Toivonen
  • 21,690
  • 47
  • 129
  • 225
  • 1
    Possible duplicate of [Git - Difference Between 'assume-unchanged' and 'skip-worktree'](http://stackoverflow.com/questions/13630849/git-difference-between-assume-unchanged-and-skip-worktree) – MrTux Oct 14 '16 at 08:25

3 Answers3

0

You are probably looking for skip-worktree.

git update-index --skip-worktree <file>

When this flag is applied to a file, it's changes are ignored. However, it won't work seamless: when changes to this file are planned by a git operation, you get a conflict/error.

For more information see:

Community
  • 1
  • 1
MrTux
  • 32,350
  • 30
  • 109
  • 146
-1

write .gitignore file on your root directory of project. and add this file path into .gitignore file. You should remove Application.xml file from repo first.

-2

Add this file to your .gitignore files. And clean cache use this code:

git rm --cached <file>

If you want do not want to track .gitignore file, just run:

git rm --cached .gitignore
haiyang
  • 310
  • 3
  • 8