GitHub ignores file Setup experience

Source: Internet
Author: User
Tags glob using git

There are many files that do not have to be managed with Git. For example, eclipse or other IDE-generated project files, compilation of generated targets or temporary files, etc. When you use git status, you'll see the list of these files in the untracked files, which is a long time to add (using git add). /git add-u), all these non-tracked files will be added to the index.

============ Some grumbling ============ so naturally want to tell git to ignore these files, we will certainly think of Google, enter the title of this article keyword (some people will go directly to the document), then of course there will be many solutions,     Most tell us to add a list of files to be ignored in the. gitignore file; The problem is likely to persist. Again Google, this time may find help.github.com or StackOverflow, see some of the original discussion; It is important to ensure that the files are not being tracked by git before you add the ignore files to the. Gitignore, using the command git RM first- Cached filename To remove them from the index.     Finally see the solution can not help but Anxi, do-hit git status to try, the problem is likely to persist.     Too many Chinese "technical information" is copied, reproduced by the people themselves have not tried; slightly better in the English community to see the relevant discussions, the translation of a post, there may be understanding of the problem or ignore some of the details, leading to still can't solve the problem. So the search engine gives the Chinese result, there are a lot of useless to solve the problem.     Git ignoring files is common and should be a simple question, but most of the posts don't even understand the problem, and this has sparked a series of complaints. Think more about the problem, the essence of the problem, the principle of the solution, and the most important thing is to actually do it. ============ whining over ============ Solution: 1. Local warehouse ignoredFile-ignoring rules for local warehouses can be added in the. git/info/exclude file. These ignored files are not submitted to the shared library and are therefore not shared by collaborators. 2. Current working directory Add file IgnoreFor each level of working directory, create a. gitignore file that adds files or directories to the file that you want to ignore. but before you create and edit this file, make sure that the files you want to ignore are not added to the git index. Using commands git rm--cached filenameRemove the files that will be ignored from the index. --Excerpt. Gitignore format specification • All blank lines or lines beginning with the comment symbol # are ignored by Git.
• Standard Glob pattern matching can be used.
• The match pattern is followed by a backslash (/) to indicate that the directory is to be ignored.
• to ignore files or directories other than the specified pattern, you can precede the pattern with an exclamation point (!). Reverse.
The so-called glob pattern refers to the simplified regular expression used by the shell. An asterisk (*) matches 0 or more arbitrary characters; [ABC] matches any one of the characters in square brackets (this example either matches a, either matches a B, or matches a C); question mark (?) Matches only one arbitrary character, if two characters are separated by a dash in square brackets, indicating that all of the two character ranges can be matched (for example [0-9] to match all 0 to 9 digits). 2.1 The directory for each level of the working directory can have a. gitignore file that describes the files or directories that need to be ignored by git in the current directory 2.2. Gitignore files can be submitted to shared libraries and shared by collaborators 3. Global. GitignoreYou can reduce the rule duplication definition for each level of the directory by creating ~/.gitignore_global and adding to the GIT global configuration. Using commands git config--global core.excludesfile ~/.gitignore_globalCan. gitignore_global File Sample Ruby code
  1. <span style="Font-size:small;" ># Compiled Source #
  2. ###################
  3. *.com
  4. *. class
  5. *.dll
  6. *.exe
  7. *.o
  8. *.so
  9. # Packages #
  10. ############
  11. # it ' s better to unpack these files and commits the raw source
  12. # git has it own built in compression methods
  13. *.7z
  14. *.dmg
  15. *.gz
  16. *.iso
  17. *.jar
  18. *.rar
  19. *.tar
  20. *.zip
  21. # Logs and Databases #
  22. ######################
  23. *.log
  24. *.sql
  25. *.sqlite
  26. # OS generated Files #
  27. ######################
  28. . Ds_store
  29. . Ds_store?
  30. ._*
  31. . spotlight-v100
  32. . Trashes
  33. Icon?
  34. Ehthumbs.db
  35. Thumbs.db
  36. </span>

References:

1. Ignoring files, Https://help.github.com/articles/ignoring-files2. The initial use of git-ignores certain files, http://www.phperblog.net/?p=1733. git ignore file, Git adds ignore files, http://www.cnblogs.com/wucg/archive/2011/08/16/2141647.html

GitHub ignores file Setup experience

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.