如标题所示。我希望git拒绝add
文件名中包含空格的文件。是否存在强制执行此操作的配置?
的正则表达式**\ **
可以在.gitignore文件中用于拒绝带空格的文件名。
这是一个工作示例的演示:
步骤1:添加**\ **
到存储库中的.gitignore文件
$ my-repository (master)
$ ls
core/ it.tests/ pom.xml README.md ui.apps/ ui.content/
$ cat .gitignore
**/.classpath
**/target
**/node_modules/
/node_modules/
/build/
**\ **
---> Ignore file that has blank spaces in the name
步骤2:创建一个名称中带有空格的文件(示例:xy z.txt)
$ echo "Hello! How are you doing?" > "x y z.txt"
$ ls
core/ it.tests/ pom.xml README.md ui.apps/ ui.content/
'x y z.txt'
步骤3:尝试将名称中带有空格的文件添加到存储库并提交
$ git add .
$ git commit -a
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
结果:
的模式**\ **
中的.gitignore文件阻止其名称中有空格的文件被添加到库中。
有关.gitignore文件的更多信息:
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句