Automatically add .gitignore and hooks on git init

前端 未结 3 1202
闹比i
闹比i 2020-12-13 09:37

Is there a way to tell git to automatically create/populate .gitignore and certain files in the .git/hooks folder every time git init is run on a certain machin

3条回答
  •  庸人自扰
    2020-12-13 10:13

    If we are talking about a repo containing JavaScript and using npm, then you can use husky to set up commit hooks.

    npm install husky --save-dev
    
    // package.json
    {
      "husky": {
        "hooks": {
          "pre-commit": "npm test",
          "pre-push": "npm test",
          "...": "..."
        }
      }
    }
    

    This does not answer the original question directly, but may be relevant to many developers.

提交回复
热议问题