36. ファイルをコミットする <git commit> 2/2
- ファイル変更後の再コミット
$ echo 'this is bar' > foo/bar
$ echo 'this is baz' > foo/baz
$ git add foo/bar
$ git commit
# On branch master
# Your branch is ahead of 'origin/master' by 7 commits.
#
# 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: foo/bar
#
37. ファイルをコミットする <git commit> 2/2
- ファイル変更後の再コミット
$ echo 'this is bar' > foo/bar
$ echo 'this is baz' > foo/baz
$ git add foo/bar
$ git commit
# On branch master
# Your branch is barのみインデックスに登録
ahead of 'origin/master' by 7 commits.
#
# 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: foo/bar
#
bazはコミット対象外
44. 変更が加えられたファイルを表示 <git status>
- ワーキングツリーやインデックス、リポジトリの状態を分類して表示する
$ touch a b c d
$ git add b c d
$ git commit -m "c,d commited" c d
$ echo 'REWRITE' > d
$ git status
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: b
#
# 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: d
#
# Untracked files:
# (use "git add <file>..." to include in what will be
committed)
#
# a
45. 変更が加えられたファイルを表示 <git status>
- ワーキングツリーやインデックス、リポジトリの状態を分類して表示する
$ touch a b c d
$ git add b c d
$ git commit -m "c,d commited"ステージ状態(コミット待ち)
c d
$ echo 'REWRITE' > d
$ git status
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: b
#
# 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: d
#
# Untracked files:
# (use "git add <file>..." to include in what will be
committed)
# 未追跡状態
# a
63. コミットメールの見方
- プロジェクトの開発関係者にメールが通知される
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "mars".
The branch, 1.10 has been updated
via f46534818a5432b212e2a24c9d00f706ba7df5f4 (commit)
from 3759217a665beabb6f17a81c8e3b26b5c9c02920 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit f46534818a5432b212e2a24c9d00f706ba7df5f4
Author: {your_name} <{your_email}>
Date: Thu Apr 19 13:39:12 2012 +0900
first commit
-----------------------------------------------------------------------
Summary of changes:
VERSION | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
hooks/post-receive
--
mars
64. コミットメールの見方
- プロジェクトの開発関係者にメールが通知される
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "mars".
The branch, 1.10 has been updated
via f46534818a5432b212e2a24c9d00f706ba7df5f4 (commit)
from 3759217a665beabb6f17a81c8e3b26b5c9c02920 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list ブランチ情報、コミットハッシュ情報
those
revisions in full, below.
- Log -----------------------------------------------------------------
commit f46534818a5432b212e2a24c9d00f706ba7df5f4
Author: {your_name} <{your_email}>
Date: Thu Apr 19 13:39:12 2012 +0900
first commit
-----------------------------------------------------------------------
Summary of changes:
VERSION | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
hooks/post-receive
--
mars
65. コミットメールの見方
- プロジェクトの開発関係者にメールが通知される
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "mars".
The branch, 1.10 has been updated
via f46534818a5432b212e2a24c9d00f706ba7df5f4 (commit)
from 3759217a665beabb6f17a81c8e3b26b5c9c02920 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list ブランチ情報、コミットハッシュ情報
those
revisions in full, below.
- Log -----------------------------------------------------------------
commit f46534818a5432b212e2a24c9d00f706ba7df5f4
Author: {your_name} <{your_email}>
Date: Thu Apr 19 13:39:12 2012 +0900 コミットログ情報
first commit
-----------------------------------------------------------------------
Summary of changes:
VERSION | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
hooks/post-receive
--
mars
66. コミットメールの見方
- プロジェクトの開発関係者にメールが通知される
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "mars".
The branch, 1.10 has been updated
via f46534818a5432b212e2a24c9d00f706ba7df5f4 (commit)
from 3759217a665beabb6f17a81c8e3b26b5c9c02920 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list ブランチ情報、コミットハッシュ情報
those
revisions in full, below.
- Log -----------------------------------------------------------------
commit f46534818a5432b212e2a24c9d00f706ba7df5f4
Author: {your_name} <{your_email}>
Date: Thu Apr 19 13:39:12 2012 +0900 コミットログ情報
first commit
-----------------------------------------------------------------------
Summary of changes:
VERSION | 2 +-
変更されたファイルの情報
1 files changed, 1 insertions(+), 1 deletions(-)
hooks/post-receive
--
mars
69. ファイルが一方にしか存在しない 2/3
- リポジトリBでプッシュした直後のレスポンス
$ git push
To git@{fqdn}:test
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@{fqdn}:test'
To prevent you from losing history, non-fast-forward updates
were rejected
Merge the remote changes (e.g. 'git pull') before pushing
again. See the
'Note about fast-forwards' section of 'git push --help' for
details.
70. ファイルが一方にしか存在しない 2/3
- リポジトリBでプッシュした直後のレスポンス
$ git push
To git@{fqdn}:test
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@{fqdn}:test'
To prevent you from losing history, non-fast-forward updates
were rejected
Merge the remote changes (e.g. 'git pull') before pushing
again. See the
'Note about fast-forwards' section of 'git push --help' for
details.
non-fast-forwardとなり、プッシュに失敗する
71. ファイルが一方にしか存在しない 3/3
- 対策:リモートリポジトリの差分を取得後にプッシュする
$ git pull
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 2 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
From {fqdn}:test
05e23a1..ae8a6a6 master -> origin/master
Merge made by recursive.
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 d
$ git push
Counting objects: 14, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (9/9), 958 bytes, done.
Total 9 (delta 2), reused 1 (delta 0)
To git@{fqdn}:test
ae8a6a6..53fe5ce master -> master
72. ファイルが一方にしか存在しない 3/3
- 対策:リモートリポジトリの差分を取得後にプッシュする
$ git pull
remote: Counting objects: 3, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 2 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (2/2), done.
From {fqdn}:test
05e23a1..ae8a6a6 master -> origin/master
Merge made by recursive.
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 d
$ git push push成功通知
Counting objects: 14, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (9/9), 958 bytes, done.
Total 9 (delta 2), reused 1 (delta 0)
To git@{fqdn}:test
ae8a6a6..53fe5ce master -> master
73. ファイルの競合 1/3
- テストケース
1. リポジトリAでhelloファイルを「WRITE FROM REP-A」として保存
2. helloをコミットしてリモートにプッシュする
3. リポジトリBでhelloファイルを「WRITE FROM REP-B」として保存
4. helloをコミットしてリモートにプッシュする
5. この後何が起こるか?
74. ファイルの競合 2/3
- リポジトリBでhelloをプッシュした直後のレスポンス
$ git push
To git@{fqdn}:test
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@{fqdn}:test'
To prevent you from losing history, non-fast-forward updates
were rejected
Merge the remote changes (e.g. 'git pull') before pushing
again. See the
'Note about fast-forwards' section of 'git push --help' for
details.
75. ファイルの競合 2/3
- リポジトリBでhelloをプッシュした直後のレスポンス
$ git push
To git@{fqdn}:test
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@{fqdn}:test'
To prevent you from losing history, non-fast-forward updates
were rejected
Merge the remote changes (e.g. 'git pull') before pushing
again. See the
'Note about fast-forwards' section of 'git push --help' for
details.
non-fast-forwardとなり、プッシュに失敗する
79. コンフリクトファイルの修正 2/3
- リポジトリBでプルした直後のレスポンス
$ git pull
ls remote: Counting objects: 5, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From {fqdn}:test
186584c..22a1738 master -> origin/master
Auto-merging hello
CONFLICT (content): Merge conflict in hello
Automatic merge failed; fix conflicts and then commit the
result.
80. コンフリクトファイルの修正 2/3
- リポジトリBでプルした直後のレスポンス
$ git pull
ls remote: Counting objects: 5, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From {fqdn}:test
186584c..22a1738 master -> origin/master
Auto-merging hello
CONFLICT (content): Merge conflict in hello
Automatic merge failed; fix conflicts and then commit the
result.
マージ中にコンフリクトが発生
81. コンフリクトファイルの修正 3/3
- 対策:変更が加えられたファイルの一覧を表示する
$ git status
# On branch master
# Your branch and 'origin/master' have diverged,
# and have 1 and 1 different commit(s) each, respectively.
#
# Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark
resolution)
#
# both modified: hello
#
$ cat hello
<<<<<<< HEAD
WRITE FROM REP-B
=======
WRITE FROM REP-A
>>>>>>> 22a17381b6a514b0eaa511fa0c76edb7ba0bc46b
82. コンフリクトファイルの修正 3/3
- 対策:変更が加えられたファイルの一覧を表示する
$ git status
# On branch master
マージに失敗したファイルの一覧
# Your branch and 'origin/master' have diverged,
# and have 1 and 1 different commit(s) each, respectively.
#
# Unmerged paths:
# (use "git add/rm <file>..." as appropriate to mark
resolution)
#
# both modified: hello
#
$ cat hello
<<<<<<< HEAD
WRITE FROM REP-B
=======
WRITE FROM REP-A
>>>>>>> 22a17381b6a514b0eaa511fa0c76edb7ba0bc46b