技术标签: github Git git git commit
如果没有设置 -m 选项,直接运行 git commit
会出现什么情况呢?
答案是: Git
会尝试为你打开一个编辑器以填写提交信息。 如果 Git
在你对它的配置中找不到相关信息,默认会打开 vim
。如下图:
接下来,需要键盘敲 i
进入编辑模式,而后在第一行,即红色区域部分填写提交信息:
信息编辑好之后按 ESC
,键盘敲 :wq
,即保存并退出:
最后你会看到控制台的返回消息:
$ git add .
$ git commit
[master 1bbbda5] init hello
1 file changed, 1 insertion(+)
create mode 100644 hello.js
# 方式 1
git commit -m <msg>
# 方式 2
git commit --message=<msg>
描述 :使用给定 msg
作为提交消息,即 Git
就不会打开编辑器了,也就省略了上面的步骤了。
注意 :-m
和 -c
-C
-F
是相互排斥的!
# 方式 1
git commit -a
# 方式 2
git commit --all
描述 :修改文件后不需要执行 git add
命令,直接就可以提交。
注意 :新建的文件除外!
# 方式 1
git commit -p
# 方式 2
git commit --patch
描述 :使用交互式界面来选择要提交的更改,让用户有机会在将修改后的内容提交前查看差异。
使用示范 :
$ git commit -p
diff --git a/hello.js b/hello.js
index 2ccb4c8..31b09bc 100644
--- a/hello.js
+++ b/hello.js
@@ -1,2 +1,3 @@ # ----这里会显示你的修改----
-let hello = 1; # ----这里会显示你的修改----
+let hello = 123;
let world = 456;
+let people = 789; # ----这里会显示你的修改----
(1/1) Stage this hunk [y,n,q,a,d,e,?]? # 此处需要输入你想要执行的操作
# --------- 下面是每个选项的意思 ----------
y - stage this hunk
n - do not stage this hunk
q - quit; do not stage this hunk or any of the remaining ones
a - stage this hunk and all later hunks in the file
d - do not stage this hunk or any of the later hunks in the file
e - manually edit the current hunk
? - print help
# --------- 上面是每个选项的意思 ----------
# 方式 1
git commit -C
# 方式 2
git commit --reuse-message=<commit>
描述 :获取现有的提交对象 commitId
,并在创建提交时重用日志消息和作者信息(包括时间戳)。换句话说就是重新使用之前提交过的信息去提交新的更改。
使用示范 :
# 先查看重用信息的 commitId
$ git log
commit aa63767da23f357136333b7ce18175c414b189ec (HEAD -> master)
Author: xxxxxx<xxxxxx.com>
Date: Mon Oct 25 16:30:41 2021 +0800
change hello
commit fcadef453058fb4b97b7c0cbc2994bed3a81302e
Author: xxxxxx<xxxxxx.com>
Date: Mon Oct 25 16:30:06 2021 +0800
init
# 举例:重用 init 的提交信息
$ git commit -C fcadef453058fb4b97b7c0cbc2994bed3a81302e
[master e82bdf2] init
Date: Mon Oct 25 16:30:06 2021 +0800
1 file changed, 1 insertion(+), 1 deletion(-)
结果如下:(作者,时间和信息都是一样的噢)
# 方式 1
git commit -c
# 方式 2
git commit --reedit-message=<commit>
描述 :与 -C
类似,但使用 -c
会调用编辑器,以便用户可以进一步编辑提交消息,即与 -C
相比多了一项修改编辑的步骤。
# 方式 1
git commit -n
# 方式 2
git commit --no-verify
描述 :这个选项可以绕过 pre-commit
和 commit-msg
。
描述 :通过创建新提交来替换当前分支的提交信息。
# 查看最新的提交信息
$ git log
commit 155f771f90997b88dd71d4952dee3cf15618af1b (HEAD -> master)
Author: xxxxxx<xxxxxx.com>
Date: Mon Oct 25 17:15:08 2021 +0800
edit test
commit 69322b677a3a6be363ba559610988607480677ce
Author: xxxxxx<xxxxxx.com>
Date: Mon Oct 25 17:11:30 2021 +0800
init
# 举例:将 edit test 提交信息修改为 modify test
执行命令 git commit --amend
,会出现下面的编辑界面,将红色框选区中修改为想要的信息:
结果预览:修改之后查看提交记录,发现提交信息已经按照预期进行了修改,同时需要注意 commitId
也发生了变化。
# 查看最新的提交信息
$ git log
commit 6681933eee000dcb99acc18f6c0fb246c551a7ad (HEAD -> master)
Author: xxxxxx<xxxxxx.com>
Date: Mon Oct 25 17:15:08 2021 +0800
modify test
commit 69322b677a3a6be363ba559610988607480677ce
Author: xxxxxx<xxxxxx.com>
Date: Mon Oct 25 17:11:30 2021 +0800
init
# 查看当前文件状态
$ git status
On branch master
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: test.js
no changes added to commit (use "git add" and/or "git commit -a")
# 暂存文件
$ git add .
# 将修改追加到上一次提交
$ git commit --amend
# 如果需要修改提交信息,则可以在出现编辑界面时进行修改;
# 若想保持上次提交信息,则直接退出 :q 编辑界面;
# ------------- 下面是编辑器显示内容------------
modify test
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Mon Oct 25 17:15:08 2021 +0800
#
# On branch master
# Changes to be committed:
# modified: test.js
#
~
~
~
"~/Documents/code/test/.git/COMMIT_EDITMSG" 11L, 266B
# ------------- 上面是编辑器显示内容------------
结果预览:追加提交完成, commitId
也发生了变化。
HDFS简介HDFS的Shell操作 HDFS的写数据流程网络拓扑- 节点距离计算机架感知HDFS的读数据流程NN 和 和 2NN 工作机制DataNode工作机制
虽然,经过前面的讲解,我们会实现单纯形法了,但是很多时候我们最好还是借助于工具来进行线性规划 尤其是 整数规划的时候。安装https://www.lindo.com/index.php/ls-downloads/try-lingo下载安装使用在编辑框输入目标函数和约束条件然后再点击Solver-solve。Lingo的写法:1.目标函数 max,min2.约束:以s.t....
digital item declaration language (DIDL-Lite): A subset of the Digital Item Declaration Language (DIDL), which is an XML dialect developed within ISO/MPEG21 [MPEG-21].数字项描述语言的一个子集。
aapt就是Android Asset Packaging Tool ,一般在sdk的tools中可以找到,一般是和adb之类的工具在一起。这个工具可以查看, 创建, 更新ZIP格式的文档附件(zip, jar, apk)。 也可将资源文件编译成二进制文件。 android的核心代码还没有来得及看呢,这篇我主要是讲述这几天将linux上面的这块代码一直到windows上面的经验。aapt
vue+vant实现购物车全选、单个删除功能效果展示一、html代码<div class="cart"> <ul class="cart-list"> <li class="goods" v-for="(item, index) in cartList" :key="item._id + index" > <!-- checked是自己添加 -->
写在前面HSI色彩空间是从人的视觉系统出发,直接用颜色三要素:色调(Hue)、饱和度(Saturation或Chroma)和亮度 (Intensity或Brightness)来描述色彩。H——表示颜色的相位角,是彩色最重要的属性,决定颜色的本质。红、绿、蓝分别相隔120度;互补色分别相差180度,即颜色的类别。 S——表示颜色的深浅程度,饱和度越高,颜色越深。与白色的比例有关,白色比例...
在不同的项目中经常需要conda来配置环境,这样能够实现不同版本的python和库的随意切换,并且减少了很多不必要的麻烦。这里记录下conda常用的一些基础命令,以便后续查询
Introduction A task is a semi-independent program segment with a dedicated purpose. Most modern real-time applications require multiple tasks. Additionally, these tasks often have varying de
离线语音课参考文章https://blog.csdn.net/cyf649669121/article/details/85246017官网文档https://cloud.tencent.com/document/product/607/15228官方SDK和demo下载网址https://cloud.tencent.com/document/product/607/18521如果麦克...
echarts仪表盘不靠边的解决办法仪表盘中,默认图表是水平垂直居中,如果要改外边距,用grid是不行的, 要用 center , center:['50%','50%'],第一个左,第二个上 一个整圆,要加起来小于等于359.9度,如果整360度,则开始点和结束点会重合。 series: [ { name: '外...
On his trip to Luxor and Aswan, Sagheer went to a Nubian market to buy some souvenirs for his friends and relatives. The market has some strange rules. It containsndifferent items numbered from1to...
最近发布在windows server2012 IIS8.0上的一个WebAPI项目,才几十个人在线,CPU就会出现过百情况,并且CPU一旦过百应用程序池就自动暂停掉,看到这个问题我感觉应该是程序哪个地方出了问题, 8盒16G 应该配置还是可以的。打算使用windbg找到这个问题。为了快速定位问题我就直接在生产环境安装了windbg,为了采集dump文件,我选择Procdu...