【Git】Git 基础命令 ( 添加暂存文件 git add | 提交文件至版本库 git commit | 查看版本库状态 git status | 查询文件修改 git diff )(二)

简介: 【Git】Git 基础命令 ( 添加暂存文件 git add | 提交文件至版本库 git commit | 查看版本库状态 git status | 查询文件修改 git diff )(二)

如果使用 git add file4.txt 命令 , 添加了一个文件到暂存区 , 但是没有执行 git commit 提交版本库 , 此时就会提示


Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   file4.txt


内容 , 告诉你现在需要提交版本库 , 当前版本库不干净 ;



执行过程 :


D:\Git\git-learning-course>git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   file4.txt
D:\Git\git-learning-course>


image.png


此时执行


git commit -m "add 1 files"


命令 , 提交版本库即可 ;


image.png






四、查询文件修改 git diff


打开文件 file1.txt , 对文件进行编译 , 写入一些字符串 ;


此时还没有调用 git add 和 git commit 命令 , 或者之前忘记了修改哪些文件的哪些内容 , 可以执行


git diff


命令 , 查看哪些文件进行了什么修改 ;


image.png


此时执行 git status 命令 , 可以查看哪些文件进行了修改 , 但是不知道修改了具体哪些内容 ;


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解决方案-优雅草卓伊凡
|
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规范:为什么有些公司要求变更行数限制?·优雅草卓伊凡
570 3
Git Commit规范:为什么有些公司要求变更行数限制?·优雅草卓伊凡
|
人工智能 前端开发 Java
用git rebase命令合并开发阶段中多条commit提交记录
通过 `git rebase`,可以合并多个提交记录,使开发历史更简洁清晰。操作分为 6 步:查看提交历史 (`git log --oneline`)、设置需合并的提交数 (`git rebase -i HEAD~N`)、修改动作标识为 `s`(squash)、保存退出编辑、调整提交信息、强制推送至远程仓库 (`git push -f`)。此方法适合清理本地无关提交,但若有团队协作或冲突风险,需谨慎使用以避免问题。
2793 60
|
开发工具 git
使用Git下载指定版本或指定commit
使用Git下载指定版本或指定commit
|
开发工具 git 索引
warning: You ran ‘git add’ with neither ‘-A (—all)’ or ‘—ignore-removal’,报错如何解决 git报错 ‘git add —ignore-removal <pathspec>优雅草卓伊凡
warning: You ran ‘git add’ with neither ‘-A (—all)’ or ‘—ignore-removal’,报错如何解决 git报错 ‘git add —ignore-removal <pathspec>优雅草卓伊凡
345 21
warning: You ran ‘git add’ with neither ‘-A (—all)’ or ‘—ignore-removal’,报错如何解决 git报错 ‘git add —ignore-removal <pathspec>优雅草卓伊凡
|
JavaScript 前端开发 持续交付
实际工作中 Git Commit 代码提交规范是什么样的?
实际工作中 Git Commit 代码提交规范是什么样的?
1269 7
|
前端开发 开发工具 git
Git报错处理:解决git commit时的lint-staged错误提示。
极好的,你对Git的lint-staged出了一个令人头疼的问题。让我们一起钻研一下,找到一种方法来解决一切。 首先,我们要确定你是在做什么操作时候遇到了问题。lint-staged通常在我们运行 git commit 时启动,它做的工作是在你提交之前运行一些指定的命令检查你的代码。当lint-staged报错,多半是因为检查未通过,或者它试图运行的命令存在问题。 让我们以一种图解的方式来描绘一下这个过程,就像canvas上的画面那样。git正在温柔的将你的修改捆绑起来,准备提交。突然,lint-staged走了出来,并开始盘问着Git,寻找可能的错误。如果lint-staged找到了什么
1277 24
|
存储 开发工具 数据安全/隐私保护
全面掌握 Git 基本操作与暂存技巧
本文详细介绍了 Git 的基本操作流程,包括查看文件状态、代码拉取、文件添加与提交、以及推送到服务器的步骤。同时,探讨了 Git 暂存的相关命令,如暂存、恢复和删除等,帮助开发者有效管理代码更改与版本控制。此外,还提供了如何找回暂存代码的技巧,以确保数据安全。
357 2
|
开发工具 git
GIT:如何合并已commit的信息并进行push操作
通过上述步骤,您可以有效地合并已提交的信息,并保持项目的提交历史整洁。记得在执行这些操作之前备份当前工作状态,以防万一。这样的做法不仅有助于项目维护,也能提升团队协作的效率。
1324 5