In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
            
                    
                
2025-11-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the ignore file of Git, which is very detailed and has certain reference value. Friends who are interested must finish reading it!
We know that some cache files, editor generated files and other files, we do not want to be included in the version library. But if each git add file name, one by one, this is really a very annoying operation, easy to make people run down. Still use git add. Yes! Is there any way to ignore some files that we don't want to be included in the version library? The answer is yes, you can use .gitignore and set the files you want to ignore in this file. Then use git add. These documents will not be submitted.
For example, I don't want to include swp files in the version library, and I don't need the runtime folder, so I can set it this way.
$vim .gitignore # ignore swp file * .swp # ignore runtime folder / runtime/
Let's talk about the .gitignore usage specification.
Git ignores lines that begin with # and are blank
You can use glob regular, which recurses to each directory (if you don't specify to prevent recursion)
You can start with / to prevent recursion
You can end with / to indicate the directory
Can be used! To choose the direction.
! The common usage is that we want to ignore a folder, but the index.html is retained in the folder. that
/ data/!/data/index.html
Means to ignore the / data folder but track the / data/index.html file.
Let's talk about what glob regular is, but it is actually a simplified version of regular.
It uses * to match 0 or more arbitrary characters. such as
* .php means to match files ending in .php tmp* means to match all files starting with tmp
Use? To match any character, such as
Zhou? Lun
Use [] to match any character in [], such as
[abc] means to match any one of the abc
In addition, if multiple characters are consecutive, you can use-instead, such as
[0-9] means to match any number
Use two asterisks (*) to match any intermediate directory
For example, a _.
Let's use an example to explain the use of ignore files. In general, we will ignore the / vendor directory, configuration files, log folders / log, cache files, etc.
# ignore swp file * .swp # ignore / vendor folder / vendor/# ignore configuration file / app/config/config.php# ignore / log folder / log/# ignore cache folder / runtime/
The above is how to ignore files that you do not want to add to the version library, and it is generally recommended to configure the file at the beginning to prevent unwanted files from being submitted.
The above is all the contents of the article "ignore File of Git". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





            
            About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.