Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ignore modified (but not committed) files in git?

People also ask

How do I ignore modified changes in git?

git rm --cached everything that you don't want to commit, then add a . gitignore file locally that has "*" in it. Now, no matter how much you git add, you'll never see those files in your index again.

Should git ignore be committed?

There is no explicit git ignore command: instead the . gitignore file must be edited and committed by hand when you have new files that you wish to ignore. . gitignore files contain patterns that are matched against file names in your repository to determine whether or not they should be ignored.

How do I ignore changes to a file in git?

In the Git Changes window, right-click any changed file that you want Git to ignore and choose Ignore this local item or Ignore this extension. Those menu options don't exist for tracked files.

How can I ignore files that have already been committed to the repo?

Git can only ignore files that are untracked - files that haven't been committed to the repository, yet. That's why, when you create a new repository, you should also create a . gitignore file with all the file patterns you want to ignore.


check out the git-update-index man page and the --assume-unchanged bit and related.

when I have your problem I do this

git update-index --assume-unchanged dir-im-removing/

or a specific file

git update-index --assume-unchanged config/database.yml

A newer and better option is git update-index --skip-worktree which won't be lost on a hard reset or a new change from a pull.

See the man page.

And a comparison at http://fallengamer.livejournal.com/93321.html


Use this code

git update-index --assume-unchanged file-name

What I usually do is

git stash

git whatever-else

git stash apply

git stash clear

Tracked files can't be ignored, so you'll have to remove them from your index first. Add a .gitignore that ignores the directories you don't want, then delete them, and remove any stragglers with git rm --cached.