プルリクエスト
開発者のローカルリポジトリでの変更を他の開発者に通知する機能前回作ったtestレポジトリは削除し、@ITの記事どおりにやってみる。
■作業用ディレクトリ作成 (c:\users\test\documents\hello-git-9)
test@test-PC MINGW32 /c/Users
$ cd c:/users/test/documents
test@test-PC MINGW32 /c/users/test/documents
$ mkdir hello-git-9
test@test-PC MINGW32 /c/users/test/documents
$ cd hello-git-9
test@test-PC MINGW32 /c/users/test/documents/hello-git-9
$ pwd
/c/users/test/documents/hello-git-9
$ cd c:/users/test/documents
test@test-PC MINGW32 /c/users/test/documents
$ mkdir hello-git-9
test@test-PC MINGW32 /c/users/test/documents
$ cd hello-git-9
test@test-PC MINGW32 /c/users/test/documents/hello-git-9
$ pwd
/c/users/test/documents/hello-git-9
■レポジトリ用ディレクトリ作成 (c:\users\test\documents\hello-git-9\local)
test@test-PC MINGW32 /c/users/test/documents/hello-git-9
$ mkdir local
test@test-PC MINGW32 /c/users/test/documents/hello-git-9
$ cd local
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/local
$ pwd
/c/users/test/documents/hello-git-9/local
$ mkdir local
test@test-PC MINGW32 /c/users/test/documents/hello-git-9
$ cd local
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/local
$ pwd
/c/users/test/documents/hello-git-9/local
■Gitリポジトリを作成し、README.mdファイルを作成しコミット
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/local
$ git init
Initialized empty Git repository in C:/Users/test/documents/hello-git-9/local/.g
it/
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/local (master)
$ echo "# hello-github" > README.md
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/local (master)
$ git add README.md
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/local (master)
$ git commit -m "first commit"
[master (root-commit) 5e6a371] first commit
1 file changed, 1 insertion(+)
create mode 100644 README.md
$ git init
Initialized empty Git repository in C:/Users/test/documents/hello-git-9/local/.g
it/
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/local (master)
$ echo "# hello-github" > README.md
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/local (master)
$ git add README.md
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/local (master)
$ git commit -m "first commit"
[master (root-commit) 5e6a371] first commit
1 file changed, 1 insertion(+)
create mode 100644 README.md
■リモートレポジトリ作成
GitHubページより [Start a project]をクリック

Create a new repositoryページで Repogitory nameに「hello-github」入力、[Create Repository]ボタンをクリック

作成しレポジトリのページが表示されたら、レポジトリURLのSSHボタンをクリック、表示されたURLをメモ

■リモートリポジトリを登録
次にローカルでの作業
登録済みのリモートレポジトリを確認
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/local (master)
$ git remote -v
リモートレポジトリは存在しないので何も表示されない$ git remote -v
リモートレポジトリを登録
書式:git remote add {リモート名} {レポジトリURL}
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/local (master)
$ git remote add origin git@github.com:{username}/hello-github.git
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/local (master)
$ git remote -v
origin git@github.com:{username}/hello-github.git (fetch)
origin git@github.com:{username}/hello-github.git (push)
※ {username}は自分のユーザ名$ git remote add origin git@github.com:{username}/hello-github.git
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/local (master)
$ git remote -v
origin git@github.com:{username}/hello-github.git (fetch)
origin git@github.com:{username}/hello-github.git (push)
■リモートリポジトリに反映
書式:git push {リモート名} {ブランチ名}
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/local (master)
$ git push origin master
Enter passphrase for key '/c/Users/test/.ssh/id_rsa':
Counting objects: 3, done.
Writing objects: 100% (3/3), 229 bytes | 57.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To github.com:{username}/hello-github.git
* [new branch] master -> master
$ git push origin master
Enter passphrase for key '/c/Users/test/.ssh/id_rsa':
Counting objects: 3, done.
Writing objects: 100% (3/3), 229 bytes | 57.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To github.com:{username}/hello-github.git
* [new branch] master -> master
■既存のリモートリポジトリを取得
GitHubレポジトリページで [Clone or download]ボタンをクリック、表示されたSSHのURLをメモ (HTTPSの表示だった場合は Use SSHをクリック)

ローカルでの作業
一つ上のディレクトリに移動しリモートレポジトリを取得
書式:git clone {レポジトリURL}
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/local (master)
$ cd ..
test@test-PC MINGW32 /c/users/test/documents/hello-git-9
$ pwd
/c/users/test/documents/hello-git-9
test@test-PC MINGW32 /c/users/test/documents/hello-git-9
$ git clone git@github.com:{username}/hello-github.git
Cloning into 'hello-github'...
Enter passphrase for key '/c/Users/test/.ssh/id_rsa':
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
test@test-PC MINGW32 /c/users/test/documents/hello-git-9
$ cd ..
test@test-PC MINGW32 /c/users/test/documents/hello-git-9
$ pwd
/c/users/test/documents/hello-git-9
test@test-PC MINGW32 /c/users/test/documents/hello-git-9
$ git clone git@github.com:{username}/hello-github.git
Cloning into 'hello-github'...
Enter passphrase for key '/c/Users/test/.ssh/id_rsa':
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
test@test-PC MINGW32 /c/users/test/documents/hello-git-9
プルリクエスト作成の準備
ここからが本題のプルリクエスト作成先ほど取得したレポジトリへ移動
test@test-PC MINGW32 /c/users/test/documents/hello-git-9
$ cd hello-github
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/hello-github (master)
$ pwd
/c/users/test/documents/hello-git-9/hello-github
$ cd hello-github
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/hello-github (master)
$ pwd
/c/users/test/documents/hello-git-9/hello-github
■プルリクエスト用ブラント edit-readme を作成し切り替え
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/hello-github (master)
$ git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/hello-github (master)
$ git checkout -b edit-readme
Switched to a new branch 'edit-readme'
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/hello-github (edit-read
me)
$ git status
On branch edit-readme
nothing to commit, working tree clean
$ git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/hello-github (master)
$ git checkout -b edit-readme
Switched to a new branch 'edit-readme'
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/hello-github (edit-read
me)
$ git status
On branch edit-readme
nothing to commit, working tree clean
■README.mdファイルへの変更
README.mdファイルに1行追加しステージ・コミット
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/hello-github (edit-read
me)
$ echo "Git連載記事の作業用レポジトリです。" >> README.md
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/hello-github (edit-read
me)
$ cat README.md
# hello-github
Git連載記事の作業用レポジトリです。
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/hello-github (edit-read
me)
$ git add README.md
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/hello-github (edit-read
me)
$ git commit -m "レポジトリの説明をさらに追加"
[edit-readme e43ba4f] レポジトリの説明をさらに追加
1 file changed, 1 insertion(+)
Warning: Your console font probably doesn't support Unicode. If you experience s
trange characters in the output, consider switching to a TrueType font such as C
onsolas!
me)
$ echo "Git連載記事の作業用レポジトリです。" >> README.md
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/hello-github (edit-read
me)
$ cat README.md
# hello-github
Git連載記事の作業用レポジトリです。
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/hello-github (edit-read
me)
$ git add README.md
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/hello-github (edit-read
me)
$ git commit -m "レポジトリの説明をさらに追加"
[edit-readme e43ba4f] レポジトリの説明をさらに追加
1 file changed, 1 insertion(+)
Warning: Your console font probably doesn't support Unicode. If you experience s
trange characters in the output, consider switching to a TrueType font such as C
onsolas!
■GitHub上のリポジトリへの反映
test@test-PC MINGW32 /c/users/test/documents/hello-git-9/hello-github (edit-read
me)
$ git push origin edit-readme
Enter passphrase for key '/c/Users/test/.ssh/id_rsa':
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 369 bytes | 123.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To github.com:{}/hello-github.git
* [new branch] edit-readme -> edit-readme
me)
$ git push origin edit-readme
Enter passphrase for key '/c/Users/test/.ssh/id_rsa':
Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 369 bytes | 123.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To github.com:{}/hello-github.git
* [new branch] edit-readme -> edit-readme
■プルリクエストを作成する
GitHubのレポジトリページを表示
main以外のブランチがpushされた場合、しばらくの間「Your recently pushed branches:」のメッセージが表示される。

[Compare & pull request]ボタンをクリックし、プルリクエスト作成ページへ移動
説明文等を入力し [Create pull request]ボタンをクリック

登録された

■プルリクエストをレビューする
[Merge pull request]ボタンをクリック

[Confirm merge]ボタンをクリックし確定

これでedit-renameブランチは不要になったので[Delete branch]ボタンをクリックし削除

0 件のコメント:
コメントを投稿