我是靠谱客的博主 自信星月,这篇文章主要介绍【错误记录】Git 使用报错 ( no changes added to commit (use “git add“ and/or “git commit -a“) )一、报错信息二、解决方案,现在分享给大家,希望可以做个参考。
文章目录
- 一、报错信息
- 二、解决方案
一、报错信息
修改了 Git 版本库中的 file1.txt 文件 , 直接执行
git commit -m "modify file1"
命令 , 尝试提交版本库 , 提示如下信息 ;
报错信息 :
D:Gitgit-learning-course>git commit -m "modify file1"
On branch master
Your branch is ahead of 'origin/master' by 3 commits.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: file1.txt
no changes added to commit (use "git add" and/or "git commit -a")
D:Gitgit-learning-course>

文件修改 :

二、解决方案
方案一 :
提交代码时 , 需要先 执行 git add 命令 将文件添加到 " 暂存区 " , 然后执行 git commit 命令 将文件提交到 " 版本库 " ;

直接 执行 git commit 命令 将文件提交到 " 版本库 " 是不行的 ;
方案二 :
也可以使用 git commit -a 命令 , 省去 git add 步骤 ;
如 : 修改了 file2.txt 文件 , 执行
git commit -a -m "modify file2"
命令 , 可以直接提交版本库 ;

最后
以上就是自信星月最近收集整理的关于【错误记录】Git 使用报错 ( no changes added to commit (use “git add“ and/or “git commit -a“) )一、报错信息二、解决方案的全部内容,更多相关【错误记录】Git内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
..." to mark resolution)1.问题描述2.解决方案" class="embed-responsive-item">
发表评论 取消回复