[Git] Use git add --patch for better commit history and mitigating bugs

Let‘s split our changes into separate commits. We‘ll be able to check over our changes before staging them all from the terminal. Then, we‘ll see the positive effect it has on our commit history.

git add --patch

1. Then in the cmd, we can type ‘s‘ stands for splite the changes into chunks.

2. Then type ‘q‘ stands for quite.

3. Add commit message for that part of changes

4. Then run git add --patch

5. Repeact 1-4 until all changes are included

时间: 2024-07-29 00:40:49

[Git] Use git add --patch for better commit history and mitigating bugs的相关文章

Git中将git add 与 git commit合并

修改hello.php文件 vim hello.php <?php         echo "hello world!"; ?> 查看hello.php文件 cat hello.php 查看项目文件状态 git status -s add与commit合并操作 git commit -am "合并提交" 命令行输出

git 命令 git status add rm commit mv

1.查看 git 仓库文件改动状态 Git 仓库内文件改动有 4 种状态,除了 Unmodified 状态的文件因为并未改动默认没有状态不做显示之外,其他文件改动状态都可以通过 git status 来查看 查看 Git 记录的状态 常用命令, 查看git仓库状态 git status 拿到一个git仓库,进入仓库,第一执行这个命令查看 [[email protected] ~]# cd /data/git_test/ [[email protected]-node1 git_test]# [[

痞子衡嵌入式:第一本Git命令教程(5)- 提交(commit/format-patch/am)

今天是Git系列课程第五课,上一课我们做了Git本地提交前的准备工作,今天痞子衡要讲的是Git本地提交操作. 当我们在仓库工作区下完成了文件增删改操作之后,并且使用git add将文件改动记录在暂存区之后,便可以开始将其提交到Git本地仓库. 1.本地文件改动提交git commit Git空间本地的改动完成之后可以直接提交,有如下三种提交命令选项: 1.1将暂存区内容提交git commit -m ["description"] 暂存区里目前只有app/app.c文件,我们先将其提交

分布式版本控制系统Git-----7.Git 使用git rebase合并多次commit

将多次commit合并,只保留一次提交历史. PS:在我练习的时候,将一个文件的代码做了多次修改,而且每次修改都给提交了,这几次改动的目的都一样,比如说修改RADEME.md,但是每次改动的只是一个小小的代码,但是提交历史上的显示看着会很乱,所以需要合并之前的多次提交历史. 1.首先使用git log查看一下提交历史[--oneline作用是将每个提交放在一行显示] 这样在git中看到的是4次提交(更改txt),有点冗余,需要做的是将4次commit合并为一次 2. git 压缩  git re

Git详解——add

前面说过了可以通过 add 来把改动的内容放进暂存区.这一节关于 add 再多说两点.都是基础的东西,但对新学 Git 的人可能有些用处. 1.add 后面加个点 ".":全部暂存 add 指令除了 git add 文件名 这种用法外,还可以使用 add . 来直接把工作目录下的所有改动全部放进暂存区: git status git add . git status 这个用法没什么特别的好处,但就一个字:方便.你在用的时候会更加深刻地体会到. 2.add 添加的是文件改动,而不是文件名

[Git] Rebase - 使用 Interactive 模式来精简 commit 纪录

避免过多 commit 纪录造成线图繁杂 透过 Rebase Interactive Mode?来将 commit log 进行精简 前言 在开发的过程中,会随着各种原因将代码提交至 local repository 中,并且在完成最终功能的开发后,会将 local 的变动 push 到 remote repository 中:此时为了避免过多无特别意义的 commit 纪录造成线图的繁杂,因此会透过各种方式来将 commit log 进行精简,其中处理方式多为 git reset 或 git

[Git] 还原Git上commit,但是没有push代码

直接在Idea上操作2步解决: 1. 找到: 2. 在To Commit里面填写:HEAD^,表示将commit的信息还原为上一次的,需要多次直接reset多次即可: 使用命令行:原理一样 以下内容转载: http://zhyq0826.iteye.com/blog/1671638 如果不小心commit了一个不需要commit的文件,可以对其进行撤销. 先使用git log 查看 commit日志 commit 422bc088a7d6c5429f1d0760d008d86c505f4abe

[Practical Git] Filter commit history with git log arguments

In the last lesson, we learned how to format the git log output; in this lesson we will learn how to filter down to a specific set of commits. By default, git log shows every commit in a repo. We will walk through using a bunch of options to filter o

eclips git中的add to Index无效解决

今天在使用eclips git中的add to Index,发现其无效,具体如下 问题描述: 通过export导入一个git java项目 在java工程中新增一个类文件IndicatorCalcTest.java 在eclips中选择该文件,team->add to Index,操作后该文件未显示+号 问题定位: 直接通过命令行进入IndicatorCalcTest.java文件所在目录,命令执行git add IndicatorCalcTest.java,报如下错误 C:\Users\Adm