Help us understand the problem. What is going on with this article?

サルでもできるCodeCommit コピペでgit cloneするまで

More than 3 years have passed since last update.

CodeCommitにリポジトリを作成

  1. バージニアリージョンでCodeCommitにアクセス→Get Started->リポジトリ名:sample_ripoを入力

リポジトリにアクセス出来るIAMユーザを作る

  1. IAMユーザ:codecommitを作成してアクセスキーID:XXXとシークレットアクセスキー:YYYをメモる。
  2. ポリシーのアタッチ→検索窓にcodecommitと入力→ポリシータイプ:AWSCodeCommitFullAccessを選択

ec2インスタンスにログインして、リポジトリにアクセスする

  1. ec2にec2-userでログインした後に初期設定をするスクリプト init_codecommit.shを作成して実行します。
init_codecommit.sh
#!/bin/bash

# aws cliを最新にアップデート
sudo pip install --upgrade awscli

# aws cliのconfig設定をします
mkdir ~/.aws
cat <<\_EOT_ > ~/.aws/config
[default]
region = us-east-1
_EOT_

# XXX,YYYはIAMユーザのID
cat <<\_EOT_ > ~/.aws/credentials
[default]
aws_access_key_id = XXXXXXXXXXXXXXXXXXXXXXX
aws_secret_access_key = YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
_EOT_

# gitのconfigを設定。name,email,aliasは各自の設定してください
# 以下のコマンドで設定するのと同じ事を記述
# git config --global user.name "ec2-user"
# git config --global user.email ec2-user@example.com
# git config --global credential.helper '!aws codecommit credential-helper $@'
# git config --global credential.UseHttpPath true

cat <<\_EOT_ > ~/.gitconfig
[user]
  name = ec2-user
  email = ec2-user@example.com
[credential]
  helper = !aws codecommit credential-helper $@
  UseHttpPath = true
[alias]
  co = checkout
  cm = commit
  ce = commit -v --amend
  st = status
  ss = status --branch --short
  si = status --ignored --short
  br = branch
  branches = branch -a
  remotes = remote -v
  tags = tag -l
  lg = log --graph --all --decorate --abbrev-commit --branches --date=short --pretty=format:\"%C(red)%h%C(reset) %C(green)[%ad]%C(res
et) %s %C(cyan)@%an%C(reset) %C(yellow)%d%C(reset)\"
  fp = fetch --prune
  dh = diff --histogram
  dw = diff --word-diff
  dc = diff --cached
  wc = whatchanged
[push]
  default = current
_EOT_

# testリポジトリをcloneしてみる
git clone https://git-codecommit.us-east-1.amazonaws.com/v1/repos/sample_ripo ~/samlpe_ripo
  • git リポジトリが使えるか軽く確認
リポジトリのディレクトリ確認
$ ls

移動
$ cd test_ripo

ステータス
$ git status

hogeファイルを作成
$ echo hoge > hoge

ステータス確認
$ git status

hogeファイルを追加
$ git add hoge

hogeファイルをコミット
$ git commit -m 'add hoge'

ログ表示
$ git log

りモートリポジトリへプッシュ
$ git push origin master

無事にgitが動いていれば成功だね!

関連するページ

サルでもできるCodeCommit ssh接続でgit cloneするまで

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away