【错误记录】Git 使用报错 ( no changes added to commit (use “git add“ and/or “git commit -a“) )

简介: 【错误记录】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>


image.pngimage.png

image.png

文件修改 :


image.png





二、解决方案


方案一 :


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

image.png




直接 执行 git commit 命令 将文件提交到 " 版本库 " 是不行的 ;



方案二 :


也可以使用 git commit -a 命令 , 省去 git add 步骤 ;


如 : 修改了 file2.txt 文件 , 执行


git commit -a -m "modify file2"


命令 , 可以直接提交版本库 ;


image.png

目录
相关文章
|
24天前
|
开发工具 git
【Azure App Service】App Service设置访问限制后,使用git clone代码库出现403报错
【Azure App Service】App Service设置访问限制后,使用git clone代码库出现403报错
|
1月前
|
开发工具 git
Git——commit的提交规范
Git——commit的提交规范
69 4
|
1月前
|
开发工具 对象存储 git
|
1月前
|
开发工具 Android开发 git
解决Idea报错出现Git is not installed
解决Idea报错出现Git is not installed
106 2
|
1月前
|
网络安全 开发工具 数据安全/隐私保护
Git——报错总结
Git——报错总结
28 1
|
20天前
|
测试技术 持续交付 开发工具
[译] 为何每次 Git Commit 要尽可能小?
[译] 为何每次 Git Commit 要尽可能小?
|
21天前
|
Java 开发工具 Android开发
Android Studio利用Build.gradle导入Git commit ID、Git Branch、User等版本信息
本文介绍了在Android Studio项目中通过修改`build.gradle`脚本来自动获取并添加Git的commit ID、branch名称和用户信息到BuildConfig类中,从而实现在编译时将这些版本信息加入到APK中的方法。
33 0
|
2月前
|
前端开发 JavaScript 开发工具
前端优化之路:git commit 校验拦截
前面在git分支规范那篇文章里,介绍了commit提交规范,但是想要做到高效落地执行,就需要做些别的功课。
|
2月前
|
网络安全 开发工具 git
【git】解决git报错:ssh:connect to host github.com port 22: Connection timed out 亲测有效
【git】解决git报错:ssh:connect to host github.com port 22: Connection timed out 亲测有效
488 1
|
1月前
|
IDE 开发工具 git
我是怎么写 Git Commit message 的?
我是怎么写 Git Commit message 的?
47 0