Pages

17 Nov 2012

A note about .gitignore

First of all, take a look at this page: http://gitready.com/beginner/2009/01/19/ignoring-files.html
And I'm not copying its content lol, well, this is just a note about what I've done successfully with .gitignore to ignore some folders in my project.

Steps:
  • Enter to root directory of your project, then "vi .gitignore" and enter something like:(I suppose you haven't had .gitignore in your project):
  • bin/ # ignore all folders which are named "bin"
    .settings/ # ignore all folders which are named ".settings" 

  • If there's nothing in your "bin" folders as well as ".settings" folders, your job here is done, everything you will put in those folders will not be tracked by Git. But if there's something in those folders which means Git are tracking it already, so you have to let Git know that you don't want to tracking it by these commands:
  • git rm --cached -r Your_Path/bin/
    git rm --cached -r Your_Path/.settings/
    git commit -m "Ignore folder bin and .settings"
    git push origin your_branch
    

P/S: You may doubt about removing cache then commit & push, and yeah, I did, but don't worry. Doing so just removes cache not actual files in your folders (actually I have no idea about where is cache too, but I guess it's cache of git lol), and committing & pushing just delete those folders on remote server, not on your local repository.
In short, making a ".gitignore" just tells your Git program on your computer knows that don't list changes of files in those folders when you type "git status",  and removing cache & committing & pushing just delete those folders on remote repository.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.