【问题标题】:Automatically do something after clone克隆后自动做某事
【发布时间】:2020-07-17 05:50:42
【问题描述】:

我正在使用统一。 当我开始一个新项目时,我应该这样做:

  1. git 初始化
  2. 添加.gitignore
  3. $ git flow init -d
  4. $ git lfs install
  5. 添加.gitAttribute

有没有办法自动做到这一点?比如,写一个shell脚本。

【问题讨论】:

标签: git unity3d gitlab gitignore gitattributes


【解决方案1】:

我不确定我是否完全理解你的意思,但是假设你每次开始一个新项目时都在问如何执行这一系列命令,那么创建一个别名怎么样?

您可以编辑您的~/.bash_aliases~/.bashrc 文件以具有自定义命令,例如:

# Custom git initialization
alias custom-command='git init && touch .gitignore && \
git flow init -d && git lfs install && touch /path-to-attributes/.gitAttribute'

现在每次在终端内运行custom-command,它都会自动运行以上所有内容。

【讨论】:

    【解决方案2】:
    #!/usr/bin/env sh
    
    git rev-parse --is-inside-work-tree &> /dev/null || {
      git init &&
      curl -L -o .gitignore https://github.com/github/gitignore/raw/master/Unity.gitignore &&
      git add -A &&
      git commit -m 'Add .gitignore' &&
      git flow init -d &&
      git lfs install &&
      curl -L -o .gitattributes https://github.com/alexkaratarakis/gitattributes/raw/master/Unity.gitattributes &&
      git add -A &&
      git commit -m 'Add .gitattributes'
    }
    

    将其保存在unity-init.sh 之类的文件中,然后放入PATH

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-12-29
      • 1970-01-01
      • 2012-03-29
      • 1970-01-01
      • 1970-01-01
      • 2021-10-16
      • 1970-01-01
      相关资源
      最近更新 更多