在git init之后自动提交一个空的.gitignore文件? [英] Automatically commit an empty .gitignore file after git init?

查看:134
本文介绍了在git init之后自动提交一个空的.gitignore文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过简单地触摸一个空的.gitignore文件并提交它,以空初始提交开始我所有的git存储库。我的理由与这个问题。 Baiscally,第一次提交(尾巴)没有父提交,所以各种奇怪的和意想不到的事情发生,不会发生与其他提交。

所以有什么东西就像一个post-init钩子,我可以用它来跟踪每个git init touch .gitignore&& git commit .gitignore -m初始提交?或者,我应该写我自己的自定义init命令吗?

使用 git init - 它使空的回购!改为使用 git clone 。只需使用您的空gitignore的提交创建一个存储库,并在需要此特定伪空存储库时克隆该存储库。 (如果你想在任何地方使用,你可以在github上公开托管它。)



另外,在你的本地机器上,为你想要的配置一个git alias:

  [别名] 
myinit =!git init&& touch .gitignore&& git add .gitignore&& git commit -m空gitignore

请注意,您不能使用与内置命令。


I would like to start off all my git repositories with an "empty" initial commit by simply touching an empty .gitignore file and committing it. My reasons are roughly the same as in this question. Baiscally, the first commit (the "tail") has no parent commit, so various weird and unexpected things happen that would not happen with other commits.

So is there something like a post-init hook that I can use to follow every git init with touch .gitignore && git commit .gitignore -m "Initial commit"? Or should I write my own custom init command that does this?

解决方案

If you want a commit in the repo, don't use git init - it makes empty repos! Use git clone instead. Just make one repository with a commit of your empty gitignore, and clone that whenever you want this particular pseudo-empty repository. (You could host it publicly on github if you want it available anywhere.)

Alternatively, on your local machine, make a git alias for what you want:

[alias]
    myinit = !git init && touch .gitignore && git add .gitignore && git commit -m "empty gitignore"

Note that you can't make aliases with the same name as built-in commands.

这篇关于在git init之后自动提交一个空的.gitignore文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆