Git的ignore

Wayne posted @ Fri, 24 Dec 2010 13:19:25 +0000 in Experience , 14668 readers

开始使用git。对着在线文档读了几天,一边还试着用。今天要提交一份有.svn文件的工程到git里面,想把.svn给无视掉。我是用命令行方式操作的,一开始很自然地想到 是否可以在 git add XXX 后面跟个什么选项什么的把.svn给exclude掉,或者是否可以用正则 ,比如 src/*!(.svn/*) 这样的。结果发现正则是不行的,不论我用哪种shell的正则方式。查了下 git add的命令手册,也没发现有exclude的选项……于是接着搜索,看到相关讨论还不少,stackoverflow上面的确有点不错的料。仔细看了会大致上了解了,得到.git/info/exclude里面去写,或者在.gitignore里面写,或者在core.excludefile里面写。 那么写就写吧,于是切进exclude文件,直接加进了“*/.svn/*”,然后先git rm -r --cached src/ 然后git add src/, 然后git status

。。。

居然不行!.svn目录居然还存在!!难道是匹配错了?我又改成正则的方式,试验还是不成!再改别的一些匹配方式,都不成!!

这让我很郁闷,只能接着搜答案,读文档。

 

在仔细地读了一遍gitignore的manpage之后,总算搞清楚了。它的匹配方式根本就是wildcard,并且*不表示“/”,也就是说.svn/*只能囊括.svn下的一级文件,子文件夹根本无能为力。同样的*/.svn也有毛病。正确的匹配方式应当是直截了当干干净净的

.svn/

nick_name said:
Wed, 04 May 2011 02:27:43 +0000

你连 man gitignore 都没看懂。写个P文章啊。

Avatar_small
Wayne said:
Sun, 08 May 2011 17:35:20 +0000

写这篇只是为了方便记住最后的结论:排除.svn目录要用.svn/。至于gitignore到底怎么配置怎么工作我并不太关心。等到有兴趣的时候自然会进一步仔细研究,现在只要管用就行。

话说你看懂了你跑这来干嘛?

逸川 said:
Thu, 12 May 2011 09:09:32 +0000

博主不必和缺乏家教的人一般见识

National Animal Dise said:
Thu, 03 Nov 2022 08:30:28 +0000

India’s central government and other significant bodies such as the National informatics center. Open different beneficial schemes for the Indian citizens.To help improve the country’s economic and citizen livelihood. National Animal Disease Reporting System The schemes are directed to different sectors, such agricultural sector. The NADRS is among the top developed schemes by the central government. It operates under the department of animal husbandry, dairy and fisheries through the NIC.

civaget said:
Mon, 11 Dec 2023 18:58:05 +0000

Regular SEO audits are essential for identifying and addressing issues that might be holding you back in 구글 상위노출 rankings.

civaget said:
Tue, 12 Dec 2023 15:11:01 +0000

출장샵 therapists are experts at relieving muscle tension and promoting relaxation. Try it for yourself!

civaget said:
Sun, 17 Dec 2023 10:17:13 +0000

대구오피 is a hidden gem for relaxation enthusiasts. The quality of service here is exceptional, and the results are outstanding.

civaget said:
Thu, 21 Dec 2023 11:39:30 +0000

The 오피스타 team does an excellent job curating OP content.

civaget said:
Mon, 25 Dec 2023 14:08:19 +0000

Buffering? Not on 축구중계! Your soccer experience is lag-free.

civaget said:
Wed, 27 Dec 2023 19:55:57 +0000

일산휴게텔 goes above and beyond. Their variety of massages ensures there's something for everyone, making it the ultimate relaxation spot in the city.

civaget said:
Sat, 30 Dec 2023 10:24:27 +0000

Stream with ease on 누누티비. No ads and a vast collection of movies and dramas await.

civaget said:
Sat, 06 Jan 2024 12:22:43 +0000

제주오피, where each visit is a journey to complete relaxation, offering deep tissue massages, aromatherapy, and a serene atmosphere.


Login *


loading captcha image...
(type the code from the image)
or Ctrl+Enter