0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

GitHubレポジトリ作成からpushまでを1コマンドで実行する

Last updated at Posted at 2020-03-20

1. はじめに

  • 新しく開発を始める際のGit関連の手順を簡略化したかった
  • ~/.gitconfigにレポジトリ作成からpushするコマンドを登録し、拡張サブコマンドとして実行できるようにした
  • やってること
    1. GitHubにレポジトリ作成(Private or Public)
    2. README.mdを作成
    3. .gitignoreを作成(空ファイル)
    4. git initを実行
    5. git add.を実行
    6. git commit -m "first commit"を実行
    7. git remote add origin XXXXXXXXを実行
    8. git push origin masterを実行

2. 準備

  • ~/.gitconfigに下記を追加する
    • init-ext-public: GitHubにpublicレポジトリを作成するサブコマンド
    • init-ext-private: GitHubにprivateレポジトリを作成するサブコマンド
[alias]
    init-ext-public = "!REPO=$(basename $PWD) GHUSER=$(git config --get user.name); curl -u $GHUSER https://api.github.com/user/repos -d {\\\"name\\\":\\\"$REPO\\\"} --fail; echo \"# $REPO\" >> README.md; git init; touch .gitignore; git add .; git commit -m \"first commit\"; git remote add origin https://github.com/$GHUSER/$REPO.git; git push origin master"
    init-ext-private = "!REPO=$(basename $PWD) GHUSER=$(git config --get user.name); curl -u $GHUSER https://api.github.com/user/repos -d {\\\"name\\\":\\\"$REPO\\\"\\,\\\"private\\\":\\\"true\\\"} --fail; echo \"# $REPO\" >> README.md; git init; touch .gitignore; git add .; git commit -m \"first commit\"; git remote add origin https://github.com/$GHUSER/$REPO.git; git push origin master"

3. 使い方例

  • 新しくtestrepoプロジェクトの開発を開始する場合(GitHubレポジトリはprivate)
$ cd /path/to/repo
$ mkdir testrepo && cd testrepo
$ git init-ext-private

参考

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?