- Forkボタンをおす
- 手元の開発環境にリポジトリをclone
$ git clone [email protected]:tokunami/sample.git
Cloning into 'sample'...
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 5 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (5/5), done.
Checking connectivity... done.
'sample'ディレクトリ以下にGitリポジトリが作成される
- ディレクトリ移動
$ cd sample
- cloneしたリポジトリのブランチを確認
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
現在のブランチ(ここではmaster)に*がついている
- トピックブランチを作成する
$git checkout -b work master
Switched to a new branch 'work'
- workブランチに切り替わっていることを確認
$git branch -a
master
* work
remotes/origin/HEAD -> origin/master
remotes/origin/master
workに*がついている→現在のブランチがworkになっている
$git add scode.js
- 既存ファイルを書き換えた場合は
git diffコマンドで修正が正しく行われているか確認する
$git commit -am "commit message"
[work 8a54f32] commit message
1 file changed, 6 insertions(+)
create mode 100644 scode.js
- -aオプション…ファイルの更新やファイルの削除をインデックスに加えてコミット
- -mオプション…コミットメッセージを指定してコミット
$ git push origin work
Counting objects: 4, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 363 bytes | 0 bytes/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To [email protected]:tokunami/sample.git
* [new branch] work -> work
- GitHub側のリポジトリに修正を加えたブランチとして手元のworkに相当するブランチを作る
$ git branch -a
master
* work
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/work
- ↑再終行に
/origin/workが作成されている
- pull requestボタンをおす
- 差分をチェックしてmergeする
diff, status, stashなどのサブコマンドは比較的よく使うものかと思います.使ってみると良いでしょう.
各gistはgitリポジトリになっていて,右上の方にURLをつかって手元で編集することも可能です.