-1

I'm using unity. when I start a new project I should do this:

  1. git init
  2. Add .gitignore
  3. $ git flow init -d
  4. $ git lfs install
  5. Add .gitAttribute

is there any way to do this automatically? like, write a shell script.

BehnamJef
  • 29
  • 6
  • Does this answer your question? [git hooks : is there a clone hook?](https://stackoverflow.com/questions/10228065/git-hooks-is-there-a-clone-hook) – phd Apr 05 '20 at 07:31
  • https://stackoverflow.com/search?q=%5Bgit%5D+post-clone+hook – phd Apr 05 '20 at 07:31
  • No, I want to do this manually not after clone, because I should create the unity project locally and then push it. – BehnamJef Apr 05 '20 at 09:43

2 Answers2

1

I am not sure if I understand exactly what you mean but, assuming you are asking how to execute that series of commands every time you start a new project, how about creating an alias?

You can edit your ~/.bash_aliases or ~/.bashrc file to have a custom command such as:

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

Now every time you run custom-command inside the terminal, it will run all of the above automatically.

giacomo-b
  • 394
  • 3
  • 13
0
#!/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'
}

Save it in a file like unity-init.sh and put it in PATH.

krisz
  • 2,686
  • 2
  • 11
  • 18