在閱讀此處關于移動 git 跟蹤的檔案的問題的答案后,如果您移動 git 正在跟蹤的檔案,則歷史記錄不應受到影響。然而,這不是我的經驗,所以我做錯了什么?這是我的控制臺日志
C:\scripts\Python\Cyren>mkdir archive
C:\scripts\Python\Cyren>dir
Volume in drive C has no label.
Volume Serial Number is 7C59-18A2
Directory of C:\scripts\Python\Cyren
08-May-22 22:44 <DIR> .
08-May-22 22:44 <DIR> ..
08-May-22 22:43 <DIR> archive
31-Mar-22 19:11 1,878 categories.csv
31-Mar-22 17:57 1,886 categories.txt
30-Mar-22 21:19 14,557 categories.xlsx
29-Apr-22 16:23 19,274 CyrenDopplerAPI.py
06-May-22 12:35 14,585 CyrenDopplerEnv.py
29-Apr-22 16:16 17,672 CyrenSample.py
C:\scripts\Python\Cyren>git log CyrenDopplerAPI.py
commit 4f440a2c132053ebe9c76a16e90abc1dd845d262
Author: Siggi@Reba <[email protected]>
Date: Thu May 5 15:38:58 2022 0000
rename
C:\scripts\Python\Cyren>git mv CyrenDopplerAPI.py archive
C:\scripts\Python\Cyren>dir
Volume in drive C has no label.
Volume Serial Number is 7C59-18A2
Directory of C:\scripts\Python\Cyren
08-May-22 22:48 <DIR> .
08-May-22 22:48 <DIR> ..
08-May-22 22:48 <DIR> archive
31-Mar-22 19:11 1,878 categories.csv
31-Mar-22 17:57 1,886 categories.txt
30-Mar-22 21:19 14,557 categories.xlsx
06-May-22 12:35 14,585 CyrenDopplerEnv.py
05-May-22 18:24 109 Infile.txt
06-May-22 12:35 <DIR> Logs
5 File(s) 33,015 bytes
4 Dir(s) 484,630,781,952 bytes free
C:\scripts\Python\Cyren>git status
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
renamed: CyrenDopplerAPI.py -> archive/CyrenDopplerAPI.py
renamed: CyrenSample.py -> archive/CyrenSample.py
C:\scripts\Python\Cyren>git commit -m "cleanup and archiving"
[master 1240039] cleanup and archiving
2 files changed, 0 insertions( ), 0 deletions(-)
rename Cyren/{ => archive}/CyrenDopplerAPI.py (100%)
rename Cyren/{ => archive}/CyrenSample.py (100%)
C:\scripts\Python\Cyren>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
C:\scripts\Python\Cyren>git push
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 454 bytes | 454.00 KiB/s, done.
Total 4 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/siggib007/python.git
e85489f..1240039 master -> master
C:\scripts\Python\Cyren>git log archive\CyrenDopplerAPI.py
commit 1240039a7e93993027f22979908ee4a9837a5474 (HEAD -> master, origin/master)
Author: Siggi@Reba <[email protected]>
Date: Sun May 8 22:49:03 2022 0000
cleanup and archiving
在git log
移動之前沒有顯示任何內容。我認為這意味著它被洗掉了。
順便說一句,這是相應的 github 倉庫的鏈接https://github.com/siggib007/python/tree/master/Cyren
這也不是一個孤立的事件,這是我的控制臺日志,它重現了我之前已經注意到幾次的問題。
uj5u.com熱心網友回復:
用于git log --follow
跟蹤重命名。
--follow
繼續列出重命名后的檔案歷史記錄(僅適用于單個檔案)。
您可以通過將log.follow
配置選項設定為true
:
log.follow
如果
true
,git log
將表現得好像在--follow
給出一個單一的選項時使用了該選項。這與 具有相同的限制--follow
,即它不能用于跟蹤多個檔案并且不能很好地處理非線性歷史。
設定它運行:
$ git config --global log.follow true
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/470946.html
標籤:混帐
上一篇:從直接下載URL下載檔案
下一篇:Git:拉取同事的功能分支