LoginSignup
4
7

More than 5 years have passed since last update.

インフラエンジニアに Git を1時間で伝える勉強会資料

Last updated at Posted at 2017-07-26
1 / 14

はじめに

愚者は経験に学び、賢者は歴史に学ぶ
~オットー・フォン・ビスマルク~


なりたち

Git は Linus が Linux のソース管理するために作った

  • 無料
  • 速い
  • 分散できる

みんな大好き Linux と同じなりたちなので、仲良くなれますね!


おしながき

  • フローを理解する
  • コミットする
  • データ構造から理解する
  • 複数人で使う
  • ブランチ

フローを理解する

郵便局メソッド を参照

おさえておきたい

フローの雰囲気


コミットする1

ローカル作成するパターン
以下、git status で随時確認しながら進めましょう

git init
touch readme.md
git add *
git commit -m "first commit"
git log
echo "##hello" >> readme.md
git commit -a -m "modify readme.md"
git log

git remote add origin REMOTE_REPOSITORY_URL
git remote -v
git push origin master

コミットする2

GitLab や GitHub からクローンするパターン

git clone REMOTE_REPOSITORY_URL
git remote -v
echo "add line" >> readme.md
git add *
git commit -m "create readme"
git log
echo "description" >> readme.md
git diff
git commit -a -m "add description"
git log
git push origin master

ここまでのデモ

おさえておきたい

  • status
  • log
  • clone
  • add
  • commit
  • push

データ構造から理解する

Git をボトムアップから理解する の2章を読む
(branch, tag, master, HEAD はスルー)

おさえておきたい

  • リポジトリ
  • インデックス
  • ワーキングツリー
  • コミット

ここ大事なので、わからないところは遠慮なく質問してください!


複数人で使う

git clone REMOTE_TEAM_REPOSITORY_URL

(ブラウザで `readme.md` を直接編集)

echo "description2" >> readme.md
git add readme.md
git commit -m "add description2"
git push origin master   ここで失敗します

git pull origin master
vi readme.md   適当に編集
git add readme.md
git commit -m "merge HASH"

ここまでのデモ

おさえておきたい

  • pull
  • 衝突

ブランチ・タグ

再び Git をボトムアップから理解する の2章を読む
(branch, tag, master)

git branch
git branch test
git branch
git checkout test
git branch

vi readme.md
git add readme.md
git commit -m "test commit"
git checkout test
cat readme.md

以上


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