ハードリンクはgitでは…

ファイルAをgitリポジトリに置いて,AのハードリンクBも同じリポジトリに置きます.
んで,Aを変更したら?

ハードリンクって何…と知ってたらそのまんま予想通りなかんじ.
そのまんまです.はい.なにも不思議なこともなければ面白いこともありません.

% git init
Initialized empty Git repository in /○○○○○/.git/
% echo "hogehogehogehoge" > hello.txt                        #一つ目のファイルを作ってコミットします
% git add hello.txt
% git commit -m "hello.txt"
[master (root-commit) acee5b5] hello.txt
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 hello.txt
% ln hello.txt hello2.txt                                    #ハードリンクを作ります
% git status                                                 #新しいファイルが追加されたことに
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       hello2.txt
nothing added to commit but untracked files present (use "git add" to track)
% git add hello2.txt                                         #ハードリンクもコミットします
% git commit -m "hello2.txt"
[master bd15fe1] hello2.txt
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 hello2.txt
% echo "fugafuga" >> hello.txt                               #一つ目のファイルをちょっと変更します
% git status                                                 #変更は検出されたでしょうか
# On branch master
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   hello.txt
#       modified:   hello2.txt                               #もちろん二つ目のほうのファイルも変更されたことになります
#
no changes added to commit (use "git add" and/or "git commit -a")

くそおもしろくない記事でごめんなさい.
そもそもgitだからどうのっていう話ですらない.これはひどい.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です