git-commit
git-commit
软件版本:
操作系统:ubuntu10.04
内核版本:Linux version 2.6.32-36-generic
git 版本:git version 1.7.0.4
目录:
1. 文件状态
2. 提交
2.1 git commit 与 git commit -a
2.2 添加提交信息
3. 修改/取消
4. 参考资料
1. 文件状态
一般仓库中的文件可能存在于这三种状态:
1)Untracked files → 文件未被跟踪;
2)Changes to be committed → 文件已暂存,这是下次提交的内容;
3) Changes bu not updated → 文件被修改,但并没有添加到暂存区。如果 commit 时没有带 -a 选项,这个状态下的文件不会被提交。
$git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## new file: file2## Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: file## Untracked files:# (use "git add <file>..." to include in what will be committed)## file3
2. 提交
git 提交的命令为:git commit 。
2.1 git commit 与 git commit -a
git commit 提交的是暂存区里面的内容,也就是 Changes to be committed 中的文件。
$git commit [master 5b61c29] run git commit 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 file2 $git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: file## Untracked files:# (use "git add <file>..." to include in what will be committed)## file3
git commit -a 除了将暂存区里的文件提交外,还提交 Changes bu not updated 中的文件。
$git commit -a[master bd77524] run git commit -a 1 files changed, 2 insertions(+), 0 deletions(-) create mode 100644 file2 $git status# On branch master# Untracked files:# (use "git add <file>..." to include in what will be committed)## file3
2.2 添加提交信息
如果直接运行 git commit (-a) 则会默认使用 vi 添加描述。也可以使用 git config --global core.editor
命令更改为你喜欢的编辑器。还有一个方法就是使用 -m 选项直接添加提交信息。
$git commit -a -m "commit info"
3. 修改/取消
有时候我们会发现有几个文件漏了提交或者想修改一下提交信息,又或者忘记使用 -a 选项导致一些文件没有被提交,我们希望对上一次提交进行修改,或者说取消上一次提交,这时候我们需要使用 --amend 选项。
$git commit --amend
可以对上一次提交进行修改,比如我们发现漏了 file3 没有提交,我们可以运行一下操作:
$git status# On branch master# Untracked files:# (use "git add <file>..." to include in what will be committed)## file3nothing added to commit but untracked files present (use "git add" to track) $git add file3$git commit --amend [master 671f5cc] commit --amend, add file3 1 files changed, 2 insertions(+), 0 deletions(-) create mode 100644 file2 create mode 100644 file3 $git status# On branch masternothing to commit (working directory clean)
又或者我们发现在提交时忘记使用 -a 选项,导致 Changes bu not updated 中的内容没有被提交,我们可以使用:
$git commit --amend -a
4. 参考资料
[1] 《pro git》
转载于:https://www.cnblogs.com/eddy-he/archive/2012/03/22/git_commit.html
git-commit相关推荐
- 【Git】ubuntu上git commit提交后如何保存和退出类似vim的界面,回到命令行
问题 使用 git commit 命令后,进入类似vim的界面,开始时,不知道如何保存,甚至不知道怎么退出该界面. 解决方法 1.使用 git commit 命令后,进入的是nano文本编辑器(类似v ...
- git commit之后,想撤销commit
原文 写完代码后,我们一般这样 git add . //添加所有文件 git commit -m "本功能全部完成" 执行完commit后,想撤回commit,怎么办? 这样凉拌: ...
- Git commit message和工作流规范
总体方案 Git commit日志基本规范 <type>(<scope>): <subject><BLANK LINE><body>< ...
- “ git commit”和“ git push”之间有什么区别?
在我正在学习的Git教程中, git commit用于存储您所做的更改. git push什么用? #1楼 git commit记录您对本地存储库的更改. git push使用本地更改更新 远程存储库 ...
- git commit 提交的时候报错husky > pre-commit hook failed (add --no-verify to bypass)(解决办法)
问题原因: 问题原因:pre-commit钩子惹的祸当你在终端输入git commit -m"XXX",提交代码的时候,pre-commit(客户端)钩子,它会在Git键入提交信息 ...
- git commit —amend_Git之修改commit记录
在很多影视作品里,就算主人公乘上了时光鸡,还是无法修改历史(或者说修改后造成十分严重的后果):而现在,在 Git 的强力驱动下,修改历史变得简单又相对安全. 本文叨叨修改 commit 历史的问题 应 ...
- git commit -m 与 git commit -am 的区别
字面解释的话,git commit -m用于提交暂存区的文件:git commit -am用于提交跟踪过的文件 要理解它们的区别,首先要明白git的文件状态变化周期,如下图所示 工作目录下面的所有文件 ...
- Git的撤销操作 git commit --amend
在项目中我们也经常会使用到撤销操作 使用这一节我们就讲一讲Git的撤销操作 撤销操作主要有如下几种 git commit --amend 撤销上一次提交 并讲暂存区文件重新提交 git checkou ...
- git commit -amend_最常见的Git错误都有哪些,如何解决它们?
脚本之家 你与百万开发者在一起 如果您曾经与许多开发者一起开发一个大项目,那么使用 Git 作为版本控制是一个最好的选择.不过 Git 很复杂,使用过程中经常会犯各种错误.在本文中,我将讨论程序员在使 ...
- 【Git】Git 版本管理 ( 补充提交版本 git commit --amend | 版本库提取文件 git checkout -- filename | 删除文件 git rm )
文章目录 一.补充提交版本 git commit --amend 二.版本库提取文件 git checkout -- filename 三.删除文件 git rm 一.补充提交版本 git commi ...
最新文章
- CentOS7在防火墙开启与关闭以及端口操作
- 陶哲轩实分析 习题 7.5.2
- python饼图怎么显示中文_python生成饼图解决中文乱码
- php final这个关键词代表什么,php面向对象之final关键字用法及实例
- FPGA组成、工作原理和开发流程
- 动态时间规整-DTW算法
- js请求php文件 302,采集某个 url, js 请求 200,浏览器访问 302
- JSF 2.0/2.1 生命周期简介
- HTML5中拖动功能的添加属性,html5中可拖动dragable属性及其他成员的讲解
- Python字符串怎样实现contains效果
- shell脚本实时监控进程连接数
- 【部署hadoop高可用集群】所有步骤
- Binder基本概念流程学习
- 文本分析软件-智分析 SmartAnalyze
- Zcash — 完全隐匿货币流向
- 微博上一些有用的话(四)
- 经典路径规划算法分类概述(更新中)
- 美团笔试.最大子段和
- docker进程管理(1号进程,僵尸进程详解)
- android ViewBinding
热门文章
- 使用Dockerfile脚本创建镜像
- Spring MVC--使用fastjson替换jackson来响应json数据
- 重构客户注册-基于ActiveMQ实现短信验证码生产者
- 通过IDEA查看jar包中的依赖关系
- 【已解决】可以访问Tomcat下webapp中的文件目录(间接实现下载功能)
- 移除添加的文件_文件压缩教程-文件批量压缩
- 下列哪个不是it行业技术岗位_28岁毕业进入IT互联网行业从事技术研发岗位是否还来得及...
- 4.2.3 OS之减少磁盘延迟时间的方法(交替编号、错位命名)
- 2.2.5 操作系统之调度算法(时间片轮转调度算法、优先级调度算法、多级反馈队列调度算法)
- python处理excel代码_Python实现读写Excel和修改Excel的代码