ina*_*ina 5 git shell gitignore
有一个关于自动添加的.gitignore以前的帖子,但你怎么会在指定git init的选项这表明对应.gitignore于git的初始化补充?
(换句话说,能够指定哪个 .gitignore使用)
这是否可以单独使用 git 命令或一些 shell 脚本?
如果您想依赖模板,如您链接的帖子所示,使用模板目录,您应该有不同的模板目录,每个目录都有其适当的info/exclude文件,并使用
git init -c --template=/path/to/template
Run Code Online (Sandbox Code Playgroud)
请注意,这不会创建一个.gitignore文件,而是一个.git/info/exclude文件,该文件保留在此存储库的本地,并且在推送时不会共享(不是这种情况.gitignore)
如果您不想费心创建目录,而是从 GitHub 目录中获取预定义的目录,.gitignore这个快速脚本会启动一个 repo,从 GitHub 的预定义目录中获取gitignore,并使用它进行第一次提交。
#!/bin/sh
git init .
curl -o .gitignore --fail --show-error --silent --location https://raw.github.com/github/gitignore/master/$1.gitignore
git add .gitignore && git commit -m "added gitignore from GitHub"
Run Code Online (Sandbox Code Playgroud)
调用脚本git-init-more.sh,chmod +x它,并将其放在您的路径中,然后您可以像这样调用它:
$ git init-more Perl
Run Code Online (Sandbox Code Playgroud)