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

目录
相关文章
|
10月前
|
安全 开发工具 git
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
870 5
git添加远程仓库报错To add an exception for this directory解决方案-优雅草卓伊凡
|
算法 安全 网络安全
git clone操作报错diffie-hellman-group1-sha1的解决方案
在处理这一问题时,需要确保了解相关操作的安全影响。`diffie-hellman-group1-sha1`算法被认为是不够安全的,这是因为随着计算能力的提高,`SHA-1`算法可以在合理的时间内被破解,而且其对应的 `1024位`Diffie-Hellman组也可能不够强大。因此,在确保Git操作的同时,也要考虑提升安全性的长期解决办法。强烈推荐与管理员或相关技术支持团队合作,升级和加强服务器端的安全配置。
342 12
|
API 开发工具 git
使用git pull遇到Automatic merge failed; fix conflicts and then commit the result.解决方案卓伊凡
使用git pull遇到Automatic merge failed; fix conflicts and then commit the result.解决方案卓伊凡
726 0
使用git pull遇到Automatic merge failed; fix conflicts and then commit the result.解决方案卓伊凡
|
存储 人工智能 缓存
Git Commit规范:为什么有些公司要求变更行数限制?·优雅草卓伊凡
Git Commit规范:为什么有些公司要求变更行数限制?·优雅草卓伊凡
572 3
Git Commit规范:为什么有些公司要求变更行数限制?·优雅草卓伊凡
|
开发工具 git
使用Git下载指定版本或指定commit
使用Git下载指定版本或指定commit
|
JavaScript 前端开发 持续交付
实际工作中 Git Commit 代码提交规范是什么样的?
实际工作中 Git Commit 代码提交规范是什么样的?
1272 7
|
网络协议 开发工具 git
解决 git 报错 “fatal: unable to access ‘https://github.com/.../.git‘: Recv failure Connection was rese
在使用 Git/Git小乌龟 进行代码管理的过程中,经常会遇到各种各样的问题,其中之一就是在执行 git clone 或 git pull 等操作时出现 “fatal: unable to access ‘https://github.com/…/.git’: Recv failure Connection was reset” 的报错。这个问题通常是由网络连接问题或代理设置不正确导致的。在我的个人使用经验中,我亲自尝试了四种方法,它们都能够有效地解决这个报错。个人比较推荐方法二。
9722 1
|
Shell 开发工具 git
解决git bash报错:在仓库中检测到可疑的所有权
总的来说,解决“在仓库中检测到可疑的所有权”的报错,关键在于理解和调整文件或目录的所有权。只要我们正确地设置了文件或目录的所有权,那么我们就可以避免这种问题,让Git Bash正常工作。
778 22
|
开发工具 git
git出现报错:src refspec master does not match any
git出现报错:src refspec master does not match any
1134 0
|
11月前
|
开发工具 git
Git版本控制工具合并分支merge命令操作流程
通过以上步聚焦于技术性和操作层面指南(guidance), 可以有效管理项目版本控制(version control), 并促进团队协作(collaboration).
2731 15