Memo

メモ > サーバ > 各論: Git > サーバからコミット&プッシュ

■サーバからコミット&プッシュ
一部の人のみFTPで更新し、その内容をgitに取り込めるかの試行錯誤 gitで定期的にファイルをバックアップする http://qiita.com/irxground/items/80dc6432e7d9d2b8b2a9 Gitを使いこなすための20のコマンド https://mag.osdn.jp/09/03/16/0831212/3 結論から書くと、Bitbucketのキーに書き込み権限はないので不可 GitHubならDeploy keysを登録時に「Allow write access」とすればできる GitHubとBitbucketでのDeploy keyの違い http://nemumu.hateblo.jp/entry/2014/03/12/184610 ■git用にユーザを追加
# useradd git-user # passwd git-user # usermod -a -G apache git-user # cp /home/ec2-user/.ssh/authorized_keys /home/git-user/.ssh/authorized_keys
■git用ユーザから更新できるように 以下はデプロイ時にApacheユーザから
find /var/www/html/student/ -type f -print | xargs chmod 664 find /var/www/html/student/ -type d -print | xargs chmod 775 find /var/www/html/html/student/ -type f -print | xargs chmod 664 find /var/www/html/html/student/ -type d -print | xargs chmod 775 find /var/www/html/html/student/test/ -type f -print | xargs chmod 664 find /var/www/html/html/student/test/ -type d -print | xargs chmod 775
■更新したファイルを表示
$ git status -bs ## develop...origin/develop M html/student/test/test.txt ?? html/student/test/test_add.txt $ git diff diff --git a/html/student/test/test.txt b/html/student/test/test.txt index 4871fd5..7827f81 100644 --- a/html/student/test/test.txt +++ b/html/student/test/test.txt @@ -1 +1,2 @@ test.txt +更新テスト
■コミット&プッシュ
$ git add -A $ git commit -m "Commit at $(date "+%Y-%m-%d %T")" || true
以下はBitbucketのキーでプッシュしようとした例 Bitbucketのキーには書き込み権限が無いためエラーとなる
$ git push -f origin develop:develop conq: repository access denied. access via a deployment key is read-only. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
以下はGitHubのRead権限のみを持ったキーでプッシュしようとした例 「read only」のキーである旨が表示されている
$ git push origin develop ERROR: The key you are authenticating with has been marked as read only. fatal: Could not read from remote repository.
以下はGitHubのRead/write権限を持ったキーでプッシュしようとした例 問題なくプッシュできる。ローカル側でプルもできる
$ git push origin develop Enumerating objects: 5, done. Counting objects: 100% (5/5), done. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 364 bytes | 364.00 KiB/s, done. Total 3 (delta 2), reused 0 (delta 0) remote: Resolving deltas: 100% (2/2), completed with 2 local objects. To github.com:yamano-terraport/test.git 6049160..3899f8f develop -> develop

Advertisement