【错误记录】Git 使用报错 ( no changes added to commit (use “git add“ and/or “git commit -a“) )
一、报错信息、二、解决方案
·
一、报错信息
修改了 Git 版本库中的 file1.txt 文件 , 直接执行
git commit -m "modify file1"
命令 , 尝试提交版本库 , 提示如下信息 ;
报错信息 :
D:\Git\git-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:\Git\git-learning-course>
文件修改 :
二、解决方案
方案一 :
提交代码时 , 需要先 执行 git add 命令 将文件添加到 " 暂存区 " , 然后执行 git commit 命令 将文件提交到 " 版本库 " ;
直接 执行 git commit 命令 将文件提交到 " 版本库 " 是不行的 ;
方案二 :
也可以使用 git commit -a
命令 , 省去 git add
步骤 ;
如 : 修改了 file2.txt 文件 , 执行
git commit -a -m "modify file2"
命令 , 可以直接提交版本库 ;
更多推荐
已为社区贡献42条内容
所有评论(0)