1

Well, question is quite clear. In which scenario should I use git --assume-unchanged or in what situation git rm -r --cached should be used?

Also, --skip-worktree is increasing the confusion.

Which is better to use with .gitignore?

Goal is to keep config files from getting pushed to github repo because there are often different settings on different deployment machines. Therefore, each machine would have their own config files.

Mashhood
  • 391
  • 3
  • 10

1 Answers1

2

assume-unchanged

  • It assumes that a developer shouldn’t change a file. This flag is meant for improving performance for not-changing folders like SDKs.
  • It is just for local performance issues. If Git can determine that those files changed in a lighter way, it will.
  • Local setting: The "assume-unchanged" bit is stored in your index, not in the repository itself. Thus fetch/pull/push do not propagate that setting to or from other repositories
  • Assume-unchanged should not be abused for an ignore mechanism. It is not a promise by Git that Git will always consider these paths are unmodified

rm -r --cached

  • Remove files from the working tree and from the index

  • git rm --cached remove the file from the repo and not delete it from the local file system(git rm will remove the file from local file system)

skip-worktree

  • skip-worktree is useful when you instruct git not to touch a specific file ever because developers should change it. For example, if the main repository upstream hosts some production-ready configuration files and you don’t want to accidentally commit changes to those files, --skip-worktree is exactly what you want. Refer this post in SO

Which is better to use with .gitignore?

It depeneds. If you already added the config files in your git, then it is better to use

git rm -r --cached

Check this post.

Community
  • 1
  • 1
Damodaran
  • 10,882
  • 10
  • 60
  • 81