LoginSignup
0
1

More than 5 years have passed since last update.

サクッとgit init

Last updated at Posted at 2018-10-13

概要

オリジナルgit initでサクッと新規リポジトリ作成。

準備

  • 任意な場所にbinフォルダ作成
  • .bashrcにexport PATH=$HOME/FOLDERNAME/bin:$PATHを追加
  • git-initというファイル名に下記コードをペースト
  • $ source ~/.bashrcでリロード
  • $ git-initを実行
#!/bin/bash

# Git init local & remote repository
# --------------------------------------- / git-init

# Local repository create.
git init

# Enter Git user name and e-mail.
echo "===== Gitユーザー名を入力してください:"
read gitUser
echo "===== Gitメールアドレスを入力してください:"
read gitMail

# Set Git user name and e-mail add local config.
git config --local user.name "$gitUser"
git config --local user.email "$gitMail"
git config --local --list
echo "===== Local gitconfigのユーザー情報を更新しました。"

# Empty commit.
git commit --allow-empty -m "First commit."
git log

# Enter use service name.
echo " "
echo "===== 作成先の名称を入力してください: [github or bitbucket]"
read gitService

# Enter repository name.
echo "===== 作成するリモートリポジトリ名を入力してください:"
read repositoryName

# Copy repository name.
echo "$repositoryName" | pbcopy
echo ""
echo "===== リポジトリ名["$repositoryName"]をクリップボードへコピーしました。"

# Move git service websites.
echo "===== "$gitService"へ移動します。"
if [[ $gitService = github ]]; then
    open https://github.com
    read -p "===== "$gitService"でリモートリポジトリの作成が完了したら [RETURキー] =>"
    git remote add origin git@github.com:"$gitUser"/"$repositoryName".git
elif [[ $gitService = bitbucket ]]; then
    open https://bitbucket.org
    read -p "===== "$gitService"でリモートリポジトリの作成が完了したら [RETURキー] =>"
    git remote add origin git@bitbucket.org:"$gitUser"/"$repositoryName".git
else
    echo ""
    echo "===== 終了します...."
fi

# Push to remote repository.
git push -u origin master
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1