Search my site
Main | Zombie Pub Crawl VII »

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

PrintView Printer Friendly Version

EmailEmail Article to Friend

References (7)

References allow you to track sources for this article, as well as articles that were written in response to this article.

Reader Comments (1)

An instructive post. People to really know who they want to reach and why or else, they'll have no way to know what they're trying to achieve. People need to hear this and have it drilled in their brains..
Thanks for sharing this great article.
December 31, 2014 | Unregistered CommenterJrafi Smith

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
All HTML will be escaped. Hyperlinks will be created for URLs automatically.