How to ignore changes to a file when committing with Git?

If you do not stage the changes, they will not be part of the commit, something like this:

git status
# On branch development
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   ResearchProposal.tex

Here, ResearchProposal.tex has changes, but they will not be committed by git commit.

If you have two sets of changes in a single file, some that you want to commit and some that you don't, read this.

If you've run git add on a file that you don't want to commit, you need to unstage it:

git reset HEAD <file>

like this:

$ git add ResearchProposal.tex
$ git status
# On branch development
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   ResearchProposal.tex

$ git reset HEAD ResearchProposal.tex 
Unstaged changes after reset:
M   ResearchProposal.tex

$ git status
# On branch development
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#   modified:   ResearchProposal.tex

Run the following command in your terminal:

git update-index --assume-unchanged

To make Git track the file again, simply run:

git update-index --no-assume-unchanged path/to/file.txt

Tags:

Branch

Git