Search my site
Twitter
Flickr
Archives
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):
*.[oa]
*~
*.tmproj

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

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

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):
Post:
 
All HTML will be escaped. Hyperlinks will be created for URLs automatically.