imshota / system_development_project_application_1

講義用
0 stars 0 forks source link

Github_PullRequest_second #5

Open imshota opened 3 years ago

imshota commented 3 years ago

演習5 ブランチbr-devを切り、いくつかコミットしPull Requestを出せ

作業記録

ブランチbr-devを作成して移動

% git branch br-dev
% git checkout br-dev

ファイルfoofooを追加してコミットを繰り返す

% echo pulltest > foofoo
% git add foofoo
% git commit -m "add file foofoo"
[br-dev de0935d] add file foofoo
 1 file changed, 1 insertion(+)
 % echo pulltest2 > famicon   
% git add famicon      
% git commit -m "add file famicon"
[br-dev 4dfb284] add file famicon
 1 file changed, 1 insertion(+)
 create mode 100644 famicon

プッシュして、プルリクをする

% git push -u origin br-dev
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 8 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (8/8), 730 bytes | 730.00 KiB/s, done.
Total 8 (delta 0), reused 0 (delta 0)
remote: 
remote: Create a pull request for 'br-dev' on GitHub by visiting:
remote:      https://github.com/imshota/class_pro/pull/new/br-dev
remote: 
To https://github.com/imshota/class_pro.git
 * [new branch]      br-dev -> br-dev
Branch 'br-dev' set up to track remote branch 'br-dev' from 'origin'.

-uはupstreamを設定するオプション。 次回以降,引数無しでgit push可能になる

今回のbr-devを機能ブランチと捉えれば、 リポジトリに追加する機能を作りましたと 伝える事ができる。

imshota commented 3 years ago

演習6 ブランチbr-devのPull Request上でコードにコメントし、コミットをいくつか追加しマージせよ

作業記録

プルリクエストをブラウザでGUIとして行った。 https://github.com/imshota/class_pro/pull/1/files

File Changedの"+"を押す事でコメントをする事ができる。

今回は最初

pulltest2

に対してLGTM(Looks Good To Me)とコメント

次にブラウザ上で

yammmie

を付け加えてコミットし、 so goodとコメントしてマージを行った。

imshota commented 3 years ago

演習7 受講生誰かのリポジトリをForkし、手元にCloneしてremoteを確認せよ

作業記録 こちらのリポジトリをForkさせていただいた https://github.com/drop-stones/Cpp-Programming-Language

右上のForkを押すと、自分のページにForkしたリポジトリが作成された https://github.com/imshota/Cpp-Programming-Language

早速手元にcloneする

% git clone https://github.com/imshota/Cpp-Programming-Language.git

remoteを確認してみる

% git remote -v
origin  https://github.com/imshota/Cpp-Programming-Language.git (fetch)
origin  https://github.com/imshota/Cpp-Programming-Language.git (push)

つまり、pushやfetchは自分のリポジトリに影響するのであって、fork元のリポジトリには影響しない事がわかる。

imshota commented 3 years ago

演習8 Forkしたリポジトリにコミットし、リポジトリ間Pull Requestを作成せよ。 受信したPull Request上で追加コミットを促し、コミットされたらマージせよ。

作業記録

% git remote -v
origin  https://github.com/imshota/Cpp-Programming-Language.git (fetch)
origin  https://github.com/imshota/Cpp-Programming-Language.git (push)

ファイルを追加自分のリポジトリにプッシュ

% echo how_are_you > hello  
% git add hello 
% git commit -m "nice"
[main a44919c] nice
 1 file changed, 1 insertion(+)
 create mode 100644 hello
% git push -u origin main  
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 268 bytes | 268.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/imshota/Cpp-Programming-Language.git
   fb493b7..a44919c  main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.

演習7でも述べたが、これはあくまで自分のリポジトリへのプッシュ(プルリク)である。

ブラウザ上でプルリクを出した 再びコミットするように言われたので、もう一回ファイルを追加自分のリポジトリにプッシュ

% echo one_more > time     
% git add time
% git commit -m "to_meet"
[main d7ee825] to_meet
 1 file changed, 1 insertion(+)
 create mode 100644 time
% git push -u origin main
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 265 bytes | 265.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/imshota/Cpp-Programming-Language.git
   a44919c..d7ee825  main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.

ここでプルリクの様子がわかる https://github.com/drop-stones/Cpp-Programming-Language/pull/1

imshota commented 3 years ago

演習9 GitやGitHubの操作を練習せよ

作業記録 Atcoderのコードを管理しようと思う。 リポジトリはもう作ってある。 https://github.com/imshota/my_atcoder

まずは、cloneをする。

% git clone https://github.com/imshota/Cpp-Programming-Language.git
% git remote -v
origin  https://github.com/imshota/my_atcoder.git (fetch)
origin  https://github.com/imshota/my_atcoder.git (push)

ファイルb.cppを新しく追加した後、ブランチtestに移動。

% git branch 
* master
  test
% git branch test
Switched to branch 'test'

ファイルをステージに追加

% git add b.cpp

今の状態を見てみる

% git status
On branch test
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   b.cpp

コミットする

% git commit
[test 1fd74c0] add file abc 171 B
 1 file changed, 23 insertions(+)
 create mode 100644 ABC/171/b.cpp

ブランチを移動してマージする

% git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
% git merge test     
Updating 1af97dc..10e2f34
Fast-forward
 ABC/171/b.cpp | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
 create mode 100644 ABC/171/b.cpp

プッシュする

% git push -u origin master
Enumerating objects: 8, done.
Counting objects: 100% (8/8), done.
Delta compression using up to 8 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 596 bytes | 596.00 KiB/s, done.
Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/imshota/my_atcoder.git
   1af97dc..10e2f34  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.