`

Git Commit

Git 
阅读更多
let’s assume that you have a directory containing three files, and you stage them all and commit. Staging the files checksums each one (the SHA-1 hash we mentioned in Chapter 1), stores that version of the file in the Git repository (Git refers to them as blobs), and adds that checksum to the staging area:

$ git add README test.rb LICENSE
$ git commit -m 'initial commit of my project'
When you create the commit by running git commit, Git checksums each subdirectory (in this case, just the root project directory) and stores those tree objects in the Git repository. Git then creates a commit object that has the metadata and a pointer to the root project tree so it can re-create that snapshot when needed.

Your Git repository now contains five objects: one blob for the contents of each of your three files, one tree that lists the contents of the directory and specifies which file names are stored as which blobs, and one commit with the pointer to that root tree and all the commit metadata.


This looks a bit different than the hotfix merge you did earlier. In this case, your development history has diverged from some older point. Because the commit on the branch you’re on isn’t a direct ancestor of the branch you’re merging in, Git has to do some work. In this case, Git does a simple three-way merge, using the two snapshots pointed to by the branch tips and the common ancestor of the two. Figure 3-16 highlights the three snapshots that Git uses to do its merge in this case.



Figure 3-16. Git automatically identifies the best common-ancestor merge base for branch merging.
Instead of just moving the branch pointer forward, Git creates a new snapshot that results from this three-way merge and automatically creates a new commit that points to it (see Figure 3-17). This is referred to as a merge commit and is special in that it has more than one parent.

It’s worth pointing out that Git determines the best common ancestor to use for its merge base; this is different than CVS or Subversion (before version 1.5), where the developer doing the merge has to figure out the best merge base for themselves. This makes merging a heck of a lot easier in Git than in these other systems.



Figure 3-17. Git automatically creates a new commit object that contains the merged work.
Now that your work is merged in, you have no further need for the iss53 branch. You can delete it and then manually close the ticket in your ticket-tracking system:
分享到:
评论

相关推荐

    idea git commit插件

    idea commit 模板插件

    git的commit模板及commit规范校验工具一键安装

    使用方式: 1、解压package.rar package.rar 2、进入package文件夹,右键打开git bash 3、执行 sh install.sh 进行...4、执行git init 命令,查看当前目录是否生成 .git/gitcommit 和 .git/hooks/commit-msg 验证

    git commit template

    personal used template for git commit. including category/bug id...

    使用CLIprompt轻松编辑gitcommit

    在Git中,提交(commit)是记录代码更改的基本单元,而`git commit`命令则是用来创建新提交的关键操作。本篇文章将聚焦于如何使用一个名为CLIprompt的命令行实用程序来提升`git commit`的编辑体验,特别是针对Node....

    详解git commit --amend 用法

    在 Git 中,`git commit --amend` 是一个强大的命令,用于修改最近一次提交的内容或消息。这个命令对于修正错误的提交信息或整合连续的提交非常有用。下面我们将详细探讨 `git commit --amend` 的使用方法及其适用...

    04Git入门第一次提交 git commit

    04★Git入门★第一次提交_git_commit

    last-commit-log:Node.js模块获取最新的git commit信息-主要由CICD和构建阶段使用

    最后提交日志 Node.js模块可获取最新的git commit信息-主要由CI / CD和构建阶段使用。谁在用 :star: :star: :star: :star: :star: :star: :star: :star: :star:用法 const LCL = require ( 'last-commit-log' ) ;...

    commit-msg-linter:git commit消息linter钩子

    欢迎来到git-commit-msg-linter :waving_hand: :eyes: 立即查看您的每条git commit消息 :rocket: 。 一个git“ commit-msg”挂钩,用于根据流行的来替换您的git commit消息。 作为一个挂钩,它将在每次提交时运行...

    gitlog:从 git commit 消息管理更改日志

    从 git commit 消息管理更改日志 命令 有2个可执行命令: bin/控制台 gitlog:branch [path_to_repo] 显示 repo 的分支。 bin/控制台 gitlog:commit [path_to_repo] 显示或导出日志。 该命令支持以下参数: --...

    git commit提交信息修改

    1. **`git commit` 命令**: 当你对代码进行了修改并希望保存这些更改时,通常会使用 `git add` 添加到暂存区,然后通过 `git commit` 创建一个新的提交。提交信息应该清晰、简洁且遵循一定的规范,例如Angular的...

    Python-基于gitcommit生成时间计算自己的加班时长

    本主题聚焦于一个具体的实践案例——"Python-基于gitcommit生成时间计算自己的加班时长",它是一个巧妙的方法,通过分析 Git 提交历史来估算个人的加班时间。 Git 是一个分布式版本控制系统,开发者用它来管理项目...

    git-committer:一个用来生成 git commit 提交记录的 node.js 脚本

    :slot_machine: git-committerA node.js script to generate a git commit commit record.一个用来生成 git commit 提交记录的 node.js 脚本用来填满 github 绿色小方块(或者其他用途).BeforeAfter :sparkles: :...

    git-precommit-branch-name:自动将您的分支机构名称放入git commit消息中

    git-precommit-branch-name 自动将您的分支名称放入git commit消息中。 如果要在每个提交消息中添加分支名称,那么此工具正是您所需要的。 你为什么需要这个? 通常,当我们使用git时,我们将分支的名称与任务/工单...

    自己做的git笔记分享。

    git commit 文件名 -m "commit message" ``` 在提交时,可以使用-vim编辑器编辑提交信息,或者直接在命令行中指定提交信息。 #### 七、查看日志 `git log` 命令用于查看仓库的历史提交记录。常用的格式化选项包括:...

    根据模板和git commit自动生成日·周·月·年报

    根据模板和git commit自动生成日·周·月·年报

    Learning_Push:学习git commit

    "Learning_Push:学习git commit"这个主题旨在教你如何有效地使用Git的`commit`命令,它是Git的核心功能之一,对于理解Git的工作流程至关重要。在这个教程中,我们将深入探讨`commit`的用途、语法以及它在Git中的...

    bump-version:完整的[git commit&lint]→[changelog]→[release]工作流程和约定

    完整的git commit > changelog > release工作流程和约定。 现在仅适用于Node.js项目。 感谢的灵感。 安装 npm install -D @picgo/bump-version # or yarn add -D @picgo/bump-version 另外,在package.json的顶层...

    git-comment.vim:Vim插件,用于对git commit进行评论

    Git-comment.vim是一款专为Vim编辑器设计的插件,旨在方便用户在进行git commit操作时添加注释。这款插件由曲洛洛尔开发,简化了在Vim环境中编写和管理commit消息的过程,提高了代码版本控制的效率。 Git是分布式...

    git-sha1:git commit SHA1生成器的本机实现

    GIT-SHA1-COMMIT 小片段允许创建有效的git commit SHA1。 受到masak 启发安装npm install --save git-sha1-commit测试mocha用法var commit = GitSHA1.create({tree: '9bedf67800b2923982bdf60c89c57ce6fd2d9a1c',...

    fn:python库,用于基于当前时间和git commit生成文件名

    它会根据当前的git commit以及时间和日期为您提供唯一的文件名。 从终端调用fn ,文件名如下所示: 20190126-142138-244db3e-5f3a90f9 20190126-142155-244db3e-42464759 当前遵循以下格式: yyyymmdd-hhmmss-...

Global site tag (gtag.js) - Google Analytics