Search my site

Blog Posts

Entries in GIT (1)


Handy GIT Tip: Prevent local changes from being commited and pushed

Here are a couple of quick tips for dealing with ignoring files in GIT. It has saved me a lot of headaches so I am documenting them here for posterity's sake.

If the file is not yet tracked by GIT:

You can easily ignore files if they have not been previously added to the GIT repository by adding it to the .git/info/exclude file. This is extremely useful when you want to exclude text editor specific files, windows thumbnail files but do not want to include it in the main repository .gitignore file.

# git ls-files --others --exclude-from=.git/info/exclude
# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):

If the file is already being tracked:

This method is useful for when you need to maintain local changes to a file but do not want to accidentally push those changes to the main GIT Repository.

mb2:~ mark$ git update-index --assume-unchanged loc/of/file