git - 由于结帐问题,由于 git 无法添加文件
问题描述
git add .
当我在 Git bash 会话中发出命令“”时,我无法将任何文件添加到 git 。
它显示错误:
'EG' does not have a commit checked out.
fatal : adding files failed.
我现在无法在 Git 中进行任何操作。
我尝试了所有git checkout
命令,删除了分支。
我什至从我的系统中删除了 git bash。
试图在 Git GUI 中搜索提交,但我也一无所获。
做了这一切,但没有成功。请帮我。
附上我遵循的步骤的图像和我得到的错误
解决方案
嗨,让我告诉你如何使用 git 推送内容的基本步骤。只需检查您是否遵循所有这些。
如果您有一个新项目并且没有初始化 git,那么请执行以下操作:-
git init
然后,每当您在项目文件夹中进行一些更改并保存时,只需返回 git 并执行以下操作:-
git status
如果它以红色显示某些文件名,则表示这些文件已更改,现在您需要暂存要提交的更改。
因此,如果您想暂存单个文件,请复制 bash 窗口中显示的文件路径并执行
git add <file name>
否则,如果您想暂存所有更改,请执行
git add .
下一步是提交分阶段的更改,只需编写:-
git commit -m "<your commit message here>"
暂存所有文件并提交它们的一种快捷方法是
git commit -am "<your commit message here>"
提交文件后,只需执行
git push
一些有用的附加命令:-
git branch --- to know the current branch you are on
git checkout <branchname> --- to switch to some other branch
git checkout -b <branchname> --- to create a new branch
git gc --prune=now ---- to clear all the references
我希望这有帮助
推荐阅读
- ios - 为什么“UIView”类型的值没有来自引用 UIView 变量的成员?
- ruby-on-rails - heroku 容器内的 Puma 服务器无法连接到端口
- c - 为什么 Linux Open 系统调用不需要路径的缓冲区大小参数?
- java - Thymeleaf 设置不带WEB的消息资源
- python-3.x - 如何检查 var 是否存储了 '#' 或任何特殊字符
- c# - 正则表达式:两个确定器之间的匹配字符串,可能在其自身中出现
- css - Nuxtjs - 尽管输入了正确的路径,但未找到相关模块
- python - 使用 MQTT 向 Google Cloud IoT Core 中的多个设备发送命令
- json - 在 Hbase 中设置空字符串值和空字符串之间的区别?
- sql-server - 如何从 VBA Excel 返回多个 SELECT 语句