Search my site
Twitter
Flickr
Archives
Main | Zombie Pub Crawl VII »
Friday
Oct212011

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

References (11)

References allow you to track sources for this article, as well as articles that were written in response to this article.
  • Response
  • Response
    Handy GIT Tip: Prevent local changes from being commited and pushed - Posts - zarzax the blog
  • Response
    Handy GIT Tip: Prevent local changes from being commited and pushed - Posts - zarzax the blog
  • Response
    Handy GIT Tip: Prevent local changes from being commited and pushed - Posts - zarzax the blog
  • Response
    Response: west hotels
    Handy GIT Tip: Prevent local changes from being commited and pushed - Posts - zarzax the blog
  • Response
    Handy GIT Tip: Prevent local changes from being commited and pushed - Posts - zarzax the blog
  • Response
    Response: essay services
    The local commitment will be changing up on the advance level. These processing will be refining up on the same ways. These are the same procedures for the starting of new activity.
  • Response
    Handy GIT Tip: Prevent local changes from being commited and pushed - Posts - zarzax the blog
  • Response
    Response: Tactical Gear
    Handy GIT Tip: Prevent local changes from being commited and pushed - Posts - zarzax the blog
  • Response
    Response: BHPH Note Buyer
    Handy GIT Tip: Prevent local changes from being commited and pushed - Posts - zarzax the blog
  • Response
    Handy GIT Tip: Prevent local changes from being commited and pushed - Posts - zarzax the blog

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