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

目录
相关文章
|
6天前
|
开发工具 git
git 使用之remote: File [4e21e71a555febaa4dfaaa05cf7eeb606ea96ae2] size 104.090MB, exceeds quota 100MB remote: Please remove the file[s] from history and try again 报错如何解决-优雅草卓伊凡
git 使用之remote: File [4e21e71a555febaa4dfaaa05cf7eeb606ea96ae2] size 104.090MB, exceeds quota 100MB remote: Please remove the file[s] from history and try again 报错如何解决-优雅草卓伊凡
21 3
git 使用之remote: File [4e21e71a555febaa4dfaaa05cf7eeb606ea96ae2] size 104.090MB, exceeds quota 100MB remote: Please remove the file[s] from history and try again 报错如何解决-优雅草卓伊凡
|
4月前
|
存储 开发工具 数据安全/隐私保护
git报错The project you were looking for could not be found 解决方式
git报错The project you were looking for could not be found 解决方式
952 1
|
5月前
|
机器学习/深度学习 Shell 开发工具
Python使用管道执行git命令报错|4-7
Python使用管道执行git命令报错|4-7
|
5月前
|
开发工具 git
GIT:如何合并已commit的信息并进行push操作
通过上述步骤,您可以有效地合并已提交的信息,并保持项目的提交历史整洁。记得在执行这些操作之前备份当前工作状态,以防万一。这样的做法不仅有助于项目维护,也能提升团队协作的效率。
215 4
|
5月前
|
开发工具 git
GIT:如何合并已commit的信息并进行push操作
通过上述步骤,您可以有效地合并已提交的信息,并保持项目的提交历史整洁。记得在执行这些操作之前备份当前工作状态,以防万一。这样的做法不仅有助于项目维护,也能提升团队协作的效率。
311 3
|
5月前
|
存储 Shell 开发工具
8-8|windows上Git报错
8-8|windows上Git报错
|
6月前
|
开发工具 git
【Azure App Service】App Service设置访问限制后,使用git clone代码库出现403报错
【Azure App Service】App Service设置访问限制后,使用git clone代码库出现403报错
|
6月前
|
开发工具 对象存储 git
|
6月前
|
测试技术 持续交付 开发工具
[译] 为何每次 Git Commit 要尽可能小?
[译] 为何每次 Git Commit 要尽可能小?
|
6月前
|
Java 开发工具 Android开发
Android Studio利用Build.gradle导入Git commit ID、Git Branch、User等版本信息
本文介绍了在Android Studio项目中通过修改`build.gradle`脚本来自动获取并添加Git的commit ID、branch名称和用户信息到BuildConfig类中,从而实现在编译时将这些版本信息加入到APK中的方法。
153 0

相关实验场景

更多