Difference between HEAD / Working Tree / Index in Git

2024-03-26 06:20

本文主要是介绍Difference between HEAD / Working Tree / Index in Git,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

转载至http://stackoverflow.com/questions/3689838/difference-between-head-working-tree-index-in-git

A few other good references on those topics:

  • My Git Workflow

alt text

I use the index as a checkpoint.
When I’m about to make a change that might go awry — when I want to explore some direction that I’m not sure if I can follow through on or even whether it’s a good idea, such as a conceptually demanding refactoring or changing a representation type — I checkpoint my work into the index.
If this is the first change I’ve made since my last commit, then I can use the local repository as a checkpoint, but often I’ve got one conceptual change that I’m implementing as a set of little steps.
I want to checkpoint after each step, but save the commit until I’ve gotten back to working, tested code.

  • Why Git is better than X

alt text

  • Git Is Your Friend not a Foe Vol. 3: Refs and Index

They are basically named references for Git commits. There are two major types of refs: tags and heads.

  • Tags are fixed references that mark a specific point in history, for example v2.6.29.
  • On the contrary, heads are always moved to reflect the current position of project development.

alt text

Now we know what is happening in the project.
But to know what is happening right here, right now there is a special reference called HEAD. It serves two major purposes:

  • it tells Git which commit to take files from when you checkout, and
  • it tells Git where to put new commits when you commit.

When you run git checkout ref it points HEAD to the ref you’ve designated and extracts files from it. When you run git commit it creates a new commit object, which becomes a child of current HEAD. Normally HEAD points to one of the heads, so everything works out just fine.

alt text

这篇关于Difference between HEAD / Working Tree / Index in Git的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/847531

相关文章

Git的安装以及使用

一.简单介绍 1.1版本控制 版本控制是指对软件开发过程中各种程序代码,配置文件及说明文档等文件变更管理,是软件配置管理的核心思想之一。 版本控制最重要的内容是追踪文件的变更,它将什么时候,什么人更改了文件的什么内容等信息忠实的记录下来。除此之外,版本控制的另一重要的功能是并行开发。软件开发往往是多人协同作业,版本控制可以有效地解决版本的同步以及不同开发者之间的开发通信问题,提高开发效率。

Git代码管理的常用操作

在VS022中,Git的管理要先建立本地或远程仓库,然后commit到本地,最后push到远程代码库。 或者不建立本地的情况,直接拉取已有的远程代码。 Git是一个分布式版本控制系统,用于跟踪和管理文件的变化。它可以记录文件的修改历史,并且可以轻松地回滚到任何历史版本。 Git的基本概念包括: 仓库(Repository):Git使用仓库来存储文件的版本历史。一个仓库可以包含多个文件

通过sockst下载git

设置 Git 使用 SOCKS5 代理 git config --global http.proxy “socks5://localhost:1080” git config --global https.proxy “socks5://localhost:1080” 克隆仓库 git clone https://github.com/odoo/odoo.git 取消代理设置(可选) g

git clone [github]下载速度慢问题解决

将下面两个ip加入HOST 192.30.253.113 github.com 151.101.185.194 github.global.ssl.fastly.net 如果不起作用,登录 http://github.com.ipaddress.com/ (需要翻墙)输入 github.global.ssl.fastly.net 和 github.com查询对应的ip,修改host文件中的i

git fetch.git merge,git pull

git fetch origin branch1:branch2 首先执行上面的fetch操作 使用远程branch1分支在本地创建branch2(但不会切换到该分支),  如果本地不存在branch2分支, 则会自动创建一个新的branch2分支,  如果本地存在branch2分支, 并且是`fast forward', 则自动合并两个分支, 否则, 会阻止以上操作. Git pus

Eclipse使用git最基本流程

Eclipse使用git最基本流程,eclipsegit流程 git有诸多好处,网上都说的很清楚了,在这里我不再赘述。对于我来说,私下里想做一些项目,而又不能很好的保存自己的代码和进行版本控制,这时候,就用到了git。下面,就以我个人为例讲讲git从0开始如何安装使用。 Step1 准备工作 msysgit,下载地址为http://msysgit.github.io/

多头注意力机制(Multi-Head Attention)

文章目录 多头注意力机制的作用多头注意力机制的工作原理为什么使用多头注意力机制?代码示例 多头注意力机制(Multi-Head Attention)是Transformer架构中的一个核心组件。它在机器翻译、自然语言处理(NLP)等领域取得了显著的成功。多头注意力机制的引入是为了增强模型的能力,使其能够从不同的角度关注输入序列的不同部分,从而捕捉更多层次的信息。 多头注意力机

【已解决】在IDEA中使用Git拉取代码时提示:Can‘t update / master has no tracked branch

文章目录 问题描述原因分析解决方案 问题描述 在IDEA中使用Git拉取代码,尝试更新本地项目代码,提示 " Can't update / master has no tracked branch ",如下图所示: 原因分析 出现上述问题意味着本地名为master的分支(或者在很多新项目中为了更包容性已改为main作为默认分支名)并没有设置为跟踪任何远程分支。

Git 中 pull 操作和 rebase 操作的不同

由于在开发过程中,pull 操作和 rebase 操作都是用来合并分支的,所以我就常常分不清这两个操作具体有什么区别,所以才有了这篇博客来做个简单区分,具体细致差别还请移步到官方文档:Git - Reference (git-scm.com) 1)pull 操作明确来说,实际是分为了两步操作:fetch + merge fetch:进行 pull 操作的时候,git 首先会将远程仓库中的所有远

开发人员必掌握的Git常用命令备忘录清单

基础操作 1、创建ssh key,邮箱可以随便输入,不会做校验 ssh-keygen -t rsa -C "你的邮箱地址" 2、配置Git账号信息,你所有的Git操作记录,都会显示为你设置的昵称。 # 不添加`--global`表示在当前目录下的Git仓库设置,添加表示全局设置。git config --global user.name "你的Git提交昵称"# 邮箱可以随便输入,不会