3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Gitでファイルのrename前の履歴を追いたい

Last updated at Posted at 2017-09-17

こんな記事を書いておいてアレですが
http://qiita.com/gooddoog/items/a12d500b331f2ecf718f

作ったプログラムのファイル名を間違えたので直したい(CaseStatement → Case Experssion)
https://github.com/yuyabu/OrderByWithCaseStatementGenerator

過去にファイル名変更のせいでgitのlogが追えなくなったことがあった気がするので、事前調査を行いたい

検証方法

REDME.mdファイルを

This
This is
This is Test
This is Test Message

と単語を追加して編集したのちファイル名を変更。(REDME.md → README.md)

このファイルの変更履歴の確認を検証する。

ローカルでの確認

以下のコマンドで確認可能

git log --follow -p ./README.md
結果
commit 5e956b5606f0318621d3d88f27095bc523525f07
Author: yuyabu 
Date:   Sun Sep 17 16:03:31 2017 +0900

    rename

diff --git a/REDME.md b/README.md
similarity index 100%
rename from REDME.md
rename to README.md

commit 6777211baa084f59136f1a54b90dc5a0b4f2c29f
Author: yuyabu 
Date:   Sun Sep 17 15:59:17 2017 +0900

    add word

diff --git a/REDME.md b/REDME.md
index e225a40..d312b2e 100644
--- a/REDME.md
+++ b/REDME.md
@@ -1 +1 @@
-This is Test
+This is Test Message

commit 9bc5bbd9b64397535088fb1bd5f4d4abd3a94ca6
Author: yuyabu 
Date:   Sun Sep 17 15:59:03 2017 +0900

    add word

diff --git a/REDME.md b/REDME.md
index 7ab118a..e225a40 100644
--- a/REDME.md
+++ b/REDME.md
@@ -1 +1 @@
-This is 
+This is Test

commit 86ebce4d9a5a1cc10e9102467bdfba4b971a0e3b
Author: yuyabu 
Date:   Sun Sep 17 15:58:32 2017 +0900

    fix message

diff --git a/REDME.md b/REDME.md
index f0ff9a1..7ab118a 100644
--- a/REDME.md
+++ b/REDME.md
@@ -1 +1 @@
-This
+This is 

commit 2c01601a9a4e84cf8bd13135b8cd794b6a0b1cab
Author: yuyabu 
Date:   Sun Sep 17 15:56:20 2017 +0900

    first commit

diff --git a/REDME.md b/REDME.md
new file mode 100644
index 0000000..f0ff9a1
--- /dev/null
+++ b/REDME.md
@@ -0,0 +1 @@
+This

変更前の履歴が確認できた。

github上での確認

https://stackoverflow.com/questions/19101554/git-renaming-file-history-is-available-on-cmd-line-but-not-in-github-interface
によるとブランチのcommit logを

https://github.com/<user>/<project>/commits/<branch>

で確認可能
今回の場合: https://github.com/yuyabu/modifyTest/commits/master

また変更前ファイル名をURLで指定することで確認可能
https://github.com/yuyabu/modifyTest/commits/master/REDME.md

ファイル変更をまたいだ履歴を追えるChromeの拡張がある
https://stackoverflow.com/questions/17213046/see-history-in-github-after-folder-rename

所感

どれも正攻法に思えない。
ファイル名変更はイレギュラーなケースだと思うので、命名には気をつけたい

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?