在为当前项目提交 git 之前,如何解决未跟踪文件的历史列表?
How do I solve a history list of untracked files before making git commits for a current project?
我想将 2 个文本文件添加到 {master} 项目,但我不断收到与我当前项目无关的未跟踪文件列表。为什么会发生这种情况,我该如何解决? MacOS v10.15.7 Catalina 终端
添加了第一个文本文件:
git add file1.txt
添加了第二个文本文件:
git add file2.txt
查看工作目录和暂存文件:
git status
要提交的更改:
new file: file1.txt
new file: file2.txt
加上继续获取未跟踪文件列表:
.Trash/
.anaconda/
.config/
.idlerc/
.ipython/
.local/
.matplotlib/
.npm/
.spyder-py3/
.vscode/
Applications/
Creative Cloud Files/
Desktop/
Documents/
Downloads/
Library/
Moon/
Movies/
Music/
Pictures/
Public/
helloworld/
opt/
我马上删了!
rm -rf ~/.git
已检查
git status
输出
fatal: not a git repository (or any of the parent directories): .git
我会重新开始我的项目,更加清醒!
您似乎在主目录中初始化了 git。您可能希望在您正在创建的软件的项目目录中对其进行初始化。每个项目都应该有自己的 git 仓库。您可以通过将 git 存储库移动到另一个目录或使用 rm -Rf ~/.git
完全删除它来从您的主文件夹中删除它(注意:这是不可撤销的!)完成后,cd 进入 folder/project 你想跟踪并做另一个 git init
:
cd <some project folder>
git init
git add file1.txt
如果您打算将整个主目录放入 git(我不推荐这样做),则必须将所有您不想跟踪的目录和文件放入.gitignore
文件或使用 git add file1.txt
手动添加这两个文件。 Git 跟踪其目录中的任何文件,除非它们明确地放入 gitignore.
我想将 2 个文本文件添加到 {master} 项目,但我不断收到与我当前项目无关的未跟踪文件列表。为什么会发生这种情况,我该如何解决? MacOS v10.15.7 Catalina 终端
添加了第一个文本文件:
git add file1.txt
添加了第二个文本文件:
git add file2.txt
查看工作目录和暂存文件:
git status
要提交的更改:
new file: file1.txt
new file: file2.txt
加上继续获取未跟踪文件列表:
.Trash/
.anaconda/
.config/
.idlerc/
.ipython/
.local/
.matplotlib/
.npm/
.spyder-py3/
.vscode/
Applications/
Creative Cloud Files/
Desktop/
Documents/
Downloads/
Library/
Moon/
Movies/
Music/
Pictures/
Public/
helloworld/
opt/
我马上删了!
rm -rf ~/.git
已检查
git status
输出
fatal: not a git repository (or any of the parent directories): .git
我会重新开始我的项目,更加清醒!
您似乎在主目录中初始化了 git。您可能希望在您正在创建的软件的项目目录中对其进行初始化。每个项目都应该有自己的 git 仓库。您可以通过将 git 存储库移动到另一个目录或使用 rm -Rf ~/.git
完全删除它来从您的主文件夹中删除它(注意:这是不可撤销的!)完成后,cd 进入 folder/project 你想跟踪并做另一个 git init
:
cd <some project folder>
git init
git add file1.txt
如果您打算将整个主目录放入 git(我不推荐这样做),则必须将所有您不想跟踪的目录和文件放入.gitignore
文件或使用 git add file1.txt
手动添加这两个文件。 Git 跟踪其目录中的任何文件,除非它们明确地放入 gitignore.