不确定我做错了什么或误解了 git 中的一个特殊性,我有一个可以正常工作的本地存储库,但是当我使用将一些内容从外部复制到存储库中时
cp ..\folder\ -Recurse
然后只有新文件夹显示为 'tracked',而不是该文件夹内的文件,尽管文件位于 repo 内的文件夹中;
只有当我这样做时,所有文件才会被“跟踪”
cp ..\folder\* -Recurse
我错过了什么?
我正在使用 Windows 10 (20H2)、Windows Terminal (1.4.3243.0)、PowerShell 7.1.0 和 git 版本 2.28.0.windows.1
要重现它,请执行以下操作:
mkdir test_git
cd .\test_git\
mkdir from
new-item .\from\test1.txt .\from\test2.txt .\from\test3.txt
mkdir git1,git2
cd git1
git init -b main
cp ..\from\ -Recurse .
ls .\from\ # show the 3 files in the folder
git status
>On branch main
>
>No commits yet
>
>Untracked files:
> (use "git add <file>..." to include in what will be committed)
> from/
>
>nothing added to commit but untracked files present (use "git add" to track)
现在,第二种情况:
cd ..\git2\
git init -b main
cp ..\from\* -Recurse .
ls .\from\ # show the 3 files in the folder as well
git status
>On branch main
>
>No commits yet
>
>Untracked files:
> (use "git add <file>..." to include in what will be committed)
> test1.txt
> test2.txt
> test3.txt
>
>nothing added to commit but untracked files present (use "git add" to track)