Skip to content

Instantly share code, notes, and snippets.

@itokami1123dev
Last active December 11, 2015 14:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itokami1123dev/71962b4f547f8616bd5b to your computer and use it in GitHub Desktop.
Save itokami1123dev/71962b4f547f8616bd5b to your computer and use it in GitHub Desktop.
2015/12/11(金)福岡の初心者向けのGitHub勉強会

2015/12/11(金)福岡の初心者向けのGitHub勉強会

http://fukuoka-cam-study.connpass.com/event/23800/

環境の確認

コマンドがあることを確認

例)git shell を起動して黒い画面をだす

$ git --version

設定が出来ているか確認

$ git config --global --list
user.name=xxx
user.email=xxx
...

設定例

  • コミットした人の情報
$ git config --global user.name なにかしら名前
$ git config --global user.email メールアドレス
  • 色で見やすく
$ git config --global color.ui auto

GitHubにつながりますか?

ssh -T git@github.com

GitHubのアカウントもってますか?

↓ 下にログイン

https://github.com/

代表してGitHubにリポジトリを作ります

  1. 右下緑の "+ New Repository" ボタンをクリック

  2. Repository name に pull_request_study

  3. create repository

  4. "SSH"ボタンを押してください

  5. "…or create a new repository on the command line"通りにコマンドを打ちます

☆ git remote add でリモート(インターネット上のサーバ)の場所を登録してます ☆

☆ mkdir pull_request_study してその中で作業する

git push -u オプションの意味 http://qiita.com/ironsand/items/6c301fef730d53f35bc3

$ git branch -vv
  1. GitHubの画面で自分が作ったプロジェクトができていることを確認

Forkしてみましょう

さきほど作成されたGitHubのページを開いてみましょう

https://github.com/fukuoka-tonkotsu

https://github.com/fukuoka-tonkotsu/pull_request_study

右上のforkボタンを押す

↓ができます https://github.com/自分の名前/pull_request_study

$ git clone git@github.com:自分の名前/pull_request_study.git
$ cd pull_request_study

$ git status

$ git remote -v

$ git log
$ git branch

$ git branch hello-world

$ git checkout hello-world
atom .

# or

explorer .
$ git status

$ git add xxx

$ git commit

$ git push origin hello-world

GitHubページをひらく

https://github.com/ユーザ名/pull_request_study

左上のBranchをpushしたbranchの名前(hello-world)に変更してください

New pull requestボタンをクリック

下の差分を確認して Create pull request をクリック


フォーク元のページを開く

https://github.com/fukuoka-tonkotsu/pull_request_study

Pull requestのタブの数値が増えていることに気づく

Pull requestのページを開くと先ほどの内容が来ている

Merge pull requestをクリック

Confirm mergeをクリック


マージされたので最新の状態にする

$ git branch
* hello-world
  master

$ git checkout master
$ git branch
  hello-world
* master
$ git remote -v
origin  git@github.com:itokami1123dev/pull_request_study.git (fetch)
origin  git@github.com:itokami1123dev/pull_request_study.git (push)

本家をリモートを追加します

$ git remote add upstream git@github.com:fukuoka-tonkotsu/pull_request_study.git

$ git remote -v
origin  git@github.com:itokami1123dev/pull_request_study.git (fetch)
origin  git@github.com:itokami1123dev/pull_request_study.git (push)
upstream        git@github.com:fukuoka-tonkotsu/pull_request_study.git (fetch)
upstream        git@github.com:fukuoka-tonkotsu/pull_request_study.git (push)

本家の最新をとってきます

$ git fetch upstream

$ git branch -va

$ git merge upstream/master master

$ git log --oneline --graph

いったん整理

自分のリモートリポジトリ(フォーク先)を更新

$ git branch -v
# [achead xxx]を確認して

$ git push origin master

作業用に作成したトピックブランチを削除する

$ git branch -d hello-world

# 送るもの:送り先という意味
# 空っぽを送るので削除になる
$ git push origin :hello-world

二人が同じファイルをメンテして衝突させる

README.mdを二人同時に変更してpull requestを送る

pull requestは New pull requestか Compare & pull requestボタン

フォーク元の↓にpull requestがふたつ届いている状態 https://github.com/fukuoka-tonkotsu/pull_request_study/pulls

順にマージしていくと

This branch has conflicts that must be resolved 発生!!!!


2番目の人がupstreamから最新をとってマージできる形にします

$ git checkout master

$ git fetch upstream

$ git merge upstream/master master

自分のトピックブランチに反映

$ git checkout fix-read

$ git rebase master

CONFLICT (content): Merge conflict in README.md 発生!!

$ git status

both modified:   README.md

$ vim README.md

$ git add README.md

$ git rebase --continue

$ git log --oneline --graph
$ git push -f origin fix-read

Merge pull requestが押せるようになった

また、あとかたづけ

git-resetは結局何を戻すのか http://qiita.com/fnobi/items/ec036c1b5d7ee5a8517c

@itokami1123dev
Copy link
Author

pr01
pr02
pr03
pr04
pr05
pr06
pr07
pr08
pr09
pr10
pr11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment