Git で commit して push して GitLab で確認してみる
「Git でローカルリポジトリを作成してリポジトリを理解する」で、GitLab で作成したリポジトリからローカルブランチを作成できました。
次は、ローカルブランチで編集し、それを commit して push します。
その後、GitLab で結果を確認します。
git status でクリーンを確認
[~/tmp/monkey/projectx] $ git status
On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
まだ何も差分なしです。
ファイル編集
projectx には、README.md しかないので、これをメンテしてみます。
[~/tmp/monkey/projectx] $ cat README.md
これはgitクライアントをテストするためのプロジェクトです。
[~/tmp/monkey/projectx] $ vi README.md
[~/tmp/monkey/projectx] $ cat README.md
これはgitクライアントをテストするためのプロジェクトです。
私は猿です。
“git status"で確認します。
[~/tmp/monkey/projectx] $ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: README.md
no changes added to commit (use "git add" and/or "git commit -a")
README.md の編集(not staged)を検知しています。
ステージングエリアに追加
これをステージングエリアに追加します。
[~/tmp/monkey/projectx] $ git add README.md
“git status"で確認します。
[~/tmp/monkey/projectx] $ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: README.md
README.md の編集(to be committed)を検知しています。他の"not staged"はありません。
commit
ステージングエリアを commit します。
[~/tmp/monkey/projectx] $ git commit -m "自己紹介を追加"
[master 6eaee15] 自己紹介を追加
1 file changed, 3 insertions(+), 1 deletion(-)
“git status"で確認します。
[~/tmp/monkey/projectx] $ git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
ローカルブランチ master に反映されました。(on branch master)
また、リモートブランチより1つ進んでいることが示されています。
もう一つの方法でローカルブランチを確認します。
[~/tmp/monkey/projectx] $ git branch -vv
* master 6eaee15 [origin/master: ahead 1] 自己紹介を追加
リモートブランチ"origin/master"から 1 つ進んでいることがわかります。
“git push"でサーバ(名前:origin)のブランチ"master"に push します。
リモートブランチとローカルランチの名前が異なる場合は、<local name>:<remote name>
と指定します。
[~/tmp/monkey/projectx] $ git push origin master
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 311 bytes | 311.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To http://gitlab.monkey.local/mygrp/projectx.git
1100259..6eaee15 master -> master
GitLab でコミット履歴を確認する
まずは、コミットグラフを確認してみます。
projectx を開いて、サイドメニューの"Repository/Graph"を選ぶと下記のようにグラフが確認できます。
コミットポイントをクリックすると、下記のように変更内容が確認できます。
まとめ
シンプルなコミットログの作成をしました。
- 編集
- ステージングエリアへ追加 git add
- コミット git commit -m “コメント"
- サーバへ登録 git push
最近のコメント