一、报错信息



修改了 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"

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

在这里插入图片描述

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐