Nips
Nips

Reputation: 13890

How to exclude from commits but not delete?

I have a repository that has already been some files. I want to modify them locally but not commit. I don't want to delete them. I want to freeze them, how to do it?

Upvotes: 0

Views: 87

Answers (2)

Chris Mantle
Chris Mantle

Reputation: 6693

You can instruct Git to ignore changes to a tracked file like this:

git update-index --assume-unchanged [filename]

If you want Git to start taking notice of changes to that file again, you can use:

git update-index --no-assume-unchanged [filename]

One thing to be aware of with this technique. I don't think that files marked in this way are protected during a git pull or similar operation - I think they'll be overwritten. I'm not 100% sure, though.

Upvotes: 1

John
John

Reputation: 584

Create a file in your repository named .gitignore git will use its rules when looking at files to commit.

Example .gitignore.

.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

Upvotes: 0

Related Questions