我在Win 10上,我在本地工作站上有许多未提交的更改。我一直在使用GitHub桌面。
为了让第三方库工作,我认为问题是我的项目路径中的空格,我更改了文件夹名称以删除项目路径中的空格。没有帮助,我改回原来的路径。但是,我认为这引起了对GIT的打击。当我打开GitHub桌面时,我收到消息"致命:此操作必须在工作树中运行"。
运行MINGW64 bash并进行一些研究我确定缺少env变量GIT_WORK_TREE和GIT_DIR。我重置了它们,现在我得到了:
$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
deleted: .gitignore
deleted: Deploy.txt
deleted: Dialogs/copypickdlg.cpp
deleted: Dialogs/copypickdlg.h
deleted: Dialogs/popup.cpp
deleted: Dialogs/popup.h
deleted: Dialogs/prefdlg.cpp
deleted: Dialogs/prefdlg.h
deleted: Dialogs/workspacedlg.cpp
deleted: Dialogs/workspacedlg.h
deleted: Dialogs/zoomdlg.cpp
... all my files
deleted: xmp.txt
deleted: zoomdlg.ui
Untracked files:
(use "git add <file>..." to include in what will be committed)
COMMIT_EDITMSG
FETCH_HEAD
HEAD
ORIG_HEAD
config
description
hooks/
index
info/
logs/
objects/
packed-refs
refs/
no changes added to commit (use "git add" and/or "git commit -a")
所以,如果我理解正确的话,我需要添加文件:
$ git add-*.*
我是一个git新手所以我希望在继续之前确认我是对的。
答案 0 :(得分:0)
您根本不需要设置GIT_WORK_TREE和GIT_DIR git documentation很清楚:
可以自动发现
.git
位置
其默认位置位于您的仓库的根文件夹下。
取消设置这些变量并在Git bash会话中执行git状态,以检查repo是否仍被识别
cd /path/to/root/folder/of/repo
ls .git
git status