我是靠谱客的博主 自信星月,最近开发中收集的这篇文章主要介绍【错误记录】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 使用报错 ( no changes added to commit (use “git add“ and/or “git commit -a“) )一、报错信息二、解决方案所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部