Domanda

With git rm <file> a file can be deleted locally, removed from the versioning, and deleted on the repository. git rm --cached <file> does nearly the same, but keeps the file in the local working copy.

Is there possible, to remove a file/folder from the versioning (so its changes are ignored) keeping it in the repository, so that if somebody clones the repo, the file is also there, but cannot be changed with a simple add & commit?

È stato utile?

Soluzione

The short answer is no. The .gitignore facilities only prevent files from being tracked in the first place. In other words, it prevents files from entering the repository for the first time. However, once a file is tracked, it is tracked forever. All changes to that file will be tracked.

There are two general solutions. (1) Avoid adding that file to the index ever. This is just a matter of policy. (2) Place all such ignored files in an archive like UnzipMeRightAfterCloning.zip. It's an extra step for people getting into the repo, but at least the target files will never be committed.

Altri suggerimenti

Files already under Git you can ignore using

git update-index --assume-unchanged filename 

and unigtore git update-index --no-assume-unchanged filename

but, there also some interesting features, git - ignoring commited files and switch branch

Try to add the file/folder to .gitignore

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top