LoginSignup
29
16

More than 5 years have passed since last update.

Google App Script をgitで管理する

Last updated at Posted at 2019-02-10

claspを導入する

ここの手順でインストール済み。
隠しファイル・隠しフォルダの表示切り替えは[shift + command + .]でできる。

Google Apps Script API の有効化

https://script.google.com/home/usersettings
上記にアクセスして、Google Apps Script API をオンにする。
これでアカウントのGASプロジェクトをclaspで操作できるようになる。

claspにログイン

clasp login

ターミナルで上記を実行すると、ブラウザが立ち上がるのでGoogleアカウントにログインする。

プロジェクトをローカル上にcloneする

ターミナルでクローンするディレクトリに移動して、下記のコマンドを実行する。

clasp clone [スクリプトID]

スクリプトIDはファイル→プロジェクトのプロパティで確認できる。
念の為、ターミナルにコマンドを打ち込むときにスクリプトIDに[]は必要ない。

gitリポジトリの用意

好きな名前で準備する。

ターミナルからgitへpushする

git config --global user.name xxxxx
git config --global user.email xxxxx@example.com
git init
git add .
git commit -m 'First Commit'
git remote add origin https://github.com/xxxxx/xxxxx.git
git push -u origin master

-u オプションをつけることで、以後はgit pushでoriginをmasterにpushできる。

コードの変更をGASプロジェクトへ反映する

.clasp.json がある場所で以下を行う。

clasp push

これでローカルファイルをGASプロジェクトへアップロードしてくれる。

29
16
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
29
16