git_kv_store_tutorial:探索git

  • F5_708883
    了解作者
  • 7.4KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-02 04:41
    上传日期
探索Git:从git init到KV商店 这是我在发表的演讲,可以在找到幻灯片 最终演变成 为什么? 这是一个很好的借口,可以更好地了解git的内部知识,并从事一些虽然没用的但在技术上有用且有趣的事情。 为了谁? 熟悉git的任何人都不会迷路,并希望能学到一些东西。 雄心勃勃的初学者非常受欢迎,如果有什么您认为可以做得更好的事情,请:) 开始 mkdir git_exploration cd git_exploration git init 这使我们创建了一个git repo。 让我们看看我们有什么: ls -a . .. .git 如果我们在编辑器中检出.git子目录: $ tree .git .git ├── branches ├── config ├── description ├── HEAD ├── hooks │   ├── applypatch-msg.samp
git_kv_store_tutorial-master.zip
  • git_kv_store_tutorial-master
  • README.md
    19.8KB
内容介绍
# Exploring Git: From git init to a KV store #### This is a talk I gave at [ColumbusRB](http://columbusrb.com), the slides can be found [here](http://slides.com/bobbygrayson/deck-1/live#/) ## This eventually evolved into [this gem](https://www.github.com/ybur-yug/gkv) ## Why? It was a good excuse to get to know git's innards a bit better, as well as work on something that, while somewhat useless, is technically functional and interesting. ## For Who? Anyone with a casual knowledge of git shouldn't get too lost and hopefully learns something. Ambitious beginners are more than welcome, and [tweet me](https://www.twitter.com/yburyug) if something comes up that you think could make it better :) ## Beginning ```bash mkdir git_exploration cd git_exploration git init ``` This gets us a git repo created. Let's check out what we have: ``` ls -a . .. .git ``` And if we check out the `.git` subdirectory in our editor: ``` $ tree .git .git ├── branches ├── config ├── description ├── HEAD ├── hooks │   ├── applypatch-msg.sample │   ├── commit-msg.sample │   ├── post-update.sample │   ├── pre-applypatch.sample │   ├── pre-commit.sample │   ├── prepare-commit-msg.sample │   ├── pre-push.sample │   ├── pre-rebase.sample │   └── update.sample ├── info │   └── exclude ├── objects │   ├── info │   └── pack └── refs ├── heads └── tags 9 directories, 13 files ``` A note, you may need to install tree depending on your OS. On Ubuntu, I used `sudo apt-get install tree` I imagine it is about the same on mac with `brew`. I Have no idea on Windows as I barely know how to list a directory in Powershell (sorry). Okay, so this doesn't look too crazy. Let's open up some of the stuff we have on initialization in here. `.git/info/exclude` ``` # git ls-files --others --exclude-from=.git/info/exclude # Lines that start with '#' are comments. # For a project mostly in C, the following would be a good set of # exclude patterns (uncomment them if you want to use them): # *.[oa] # *~ ``` Okay, so it appears that this opens up with the command that the system would use to govern this behaviour. Knowing a bit about git, one can reasonably infer that this is going to work in hijinks with the `.gitignore` file that one can use to ignore certain files. `.git/config` ``` [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ``` It would appear this is just some general configuration for a boilerplate initialized repo. `.git/description` ``` Unnamed repository; edit this file 'description' to name the repository. ``` Here it seems we can name our little project `.git/refs/HEAD` ``` ref: refs/heads/master ``` This seems to be referencing the current `HEAD`. #### HEAD HEAD is a reference to the last commit in the current checked out branch. ## Adding A File ```bash echo "# Git Exploration" > README.md git add README.md git commit -m 'initial commit' ``` Once we do this, we can check out a new directory structure: ``` $ tree .git .git ├── branches ├── COMMIT_EDITMSG ├── config ├── description ├── HEAD ├── hooks │   ├── applypatch-msg.sample │   ├── commit-msg.sample │   ├── post-update.sample │   ├── pre-applypatch.sample │   ├── pre-commit.sample │   ├── prepare-commit-msg.sample │   ├── pre-push.sample │   ├── pre-rebase.sample │   └── update.sample ├── index ├── info │   └── exclude ├── logs │   ├── HEAD │   └── refs │   └── heads │   └── master ├── objects │   ├── 1b │   │   └── f567a9cee63cd3036628c1519b818461905b27 │   ├── 9d │   │   └── aeafb9864cf43055ae93beb0afd6c7d144bfa4 │   ├── c1 │   │   └── 2d7c0ed49ad9c7aa938743ba6fdee54b6b7fe1 │   ├── info │   └── pack └── refs ├── heads │   └── master └── tags 15 directories, 21 files ``` It appears we have some simple additions with adding one file. To start, we have expanded our info directory to now include a `logs` directory. We also have several subdirectories inside of our `objects` directory now, each containing a hash. refs subdirectory `heads` now includes a `master` file, and we also have added `COMMIT_EDITMSG`, and index at the root level of `.git`. The three hashes in our `objects` directory represent 3 data structures git utilizes. These are a `blob`, a `tree`, and a `commit`. We will go into these more in-depth later. If we examine `COMMIT_EDITMSG` we see: ``` initial commit ``` Logging our commit message. ## Making A Branch Let's create a new branch to further expand this interesting `.git` directory. ```bash git checkout -b my_feature_branch ``` What this does is use the `git checkout` command and the `-b` flag to create and checkout a new branch named whatever follows `-b`. We have created a branch called `my_feature_branch`. The reason I have called it a feature branch specifically is because this is a common flow for managing an application's development with multiple authors. Let's see what changed: ```bash $ tree .git .git ├── branches ├── COMMIT_EDITMSG ├── config ├── description ├── HEAD ├── hooks │   ├── applypatch-msg.sample │   ├── commit-msg.sample │   ├── post-update.sample │   ├── pre-applypatch.sample │   ├── pre-commit.sample │   ├── prepare-commit-msg.sample │   ├── pre-push.sample │   ├── pre-rebase.sample │   └── update.sample ├── index ├── info │   └── exclude ├── logs │   ├── HEAD │   └── refs │   └── heads │   ├── master │   └── my_feature_branch ├── objects │   ├── 1b │   │   └── f567a9cee63cd3036628c1519b818461905b27 │   ├── 9d │   │   └── aeafb9864cf43055ae93beb0afd6c7d144bfa4 │   ├── c1 │   │   └── 2d7c0ed49ad9c7aa938743ba6fdee54b6b7fe1 │   ├── info │   └── pack └── refs ├── heads │   ├── master │   └── my_feature_branch └── tags 15 directories, 23 files ``` Now, if you look at `.git/branches/refs/heads/` we can see we have added `my_feature_branch`. If we look at our `HEAD` files, we will see an addition to it as well. `.git/logs/refs/HEAD` ``` ... 1433706112 -0400 commit (initial): initial commit ... 1433796852 -0400 checkout: moving from master to my_feature_branch ``` `.git/refs/HEAD` ```bash ref: refs/heads/my_feature_branch ``` It has logged our checkout and pointed us at the new branch. Also it is worth noting we have not created any new objects. This is one of the finer pieces of git, it is differentials rather than copies and copies as one would have saving `my_documentv1`, `my_documentv2`, `my_documentvN` etc. Let's add another commit by creating a directory in here and logging its boilerplate. ``` mkdir test && echo "test" > test/file.txt cd test git status # => ./ ``` Okay, lets add this project and commit. If you don't have Volt installed locally, feel free to substitute it with anything from rails to django to meteor. It doesn't really matter for our studies here. ```bash cd .. git add test git commit -m 'add file + dir' ``` Now, let us further check out our changes in the git file tree: ``` .git ├── branches ├── COMMIT_EDITMSG ├── config ├── description ├── HEAD ├── hooks │   ├── applypatch-msg.sample │   ├── commit-msg.sample │
评论
    相关推荐
    • atombook:Atom.io 编辑器的 Gitbook 集成
      原子书 Atom.io 编辑器的集成。
    • Splitdown, 像 Markdown 编辑器替换一样的Ghost.zip
      Splitdown, 像 Markdown 编辑器替换一样的Ghost #Splitdown WordPress的Markdown 编辑器替换安装将插件克隆到插件目录中,通常位于内容/插件。你需要运行 git submodule init 和 git submodule update 来拉 show
    • svgeditor:SVG模式编辑器上的React
      Svg Shcema编辑器 在react svg + redux上进行的原理图编辑器。 版本转换为Immutable.js 事件处理的概念已经改变。 现在,这些组件不处理事件,而是将其转变为高级操作。 所有mouseDown,mouseUp,mouseMove事件均按...
    • mobile 注册表编辑器
      可以查看mobile手机的注册表,相当于windows上面的redegit
    • atom-git-grep:原子编辑器中的git-grep
      原子编辑器中的git grep 。 安装 apm install git-grep 如何使用 根据需要设置keybind.cson。 ' .workspace ' : ' cmd-k cmd-g ' : ' git-grep:grep ' # default git grep根始终是工作空间的当前根。
    • Atom-git-blame,Atom编辑器插件。切换Git.zip
      Atom-git-blame.zip,Plugin for Atom Editor. Toggle git-blame annotations for the current file in the gutter.怪罪,atom是一个用web技术构建的开源文本编辑器
    • livelesson-git
      git commit :打开文本编辑器以编写提交消息 git commit -m "MESSAGE" :将MESSAGE作为提交写入,而没有文本编辑器 git log :显示我们提交的日志(历史) git log --oneline :显示较短的git log --oneline提交 ...
    • Atom-git-commit-atom,在当前atom窗格中轻松编辑git提交消息.zip
      Atom-git-commit-atom.zip,在当前atom窗格中轻松编辑git提交消息git提交原子,atom是一个用web技术构建的开源文本编辑器
    • EditAndPublishArticle编辑器
      作者zhaoquntao,源码EditAndPublishArticle,虽然编辑和发布文章,现在很少app用到.由于公司的项目中用到了,我把这部门内容分离出来,写了一个demo分享给大家,还有一些需要完善的地方,多谢理解. gihub:/zhaoquntao/...
    • GaussDB_100_1.0.1-DATABASE-REDHAT-64bit.tar.gz
      guassdb100在redhat上安装包,单机部署的包,安装步骤请看我的文中介绍,经过大量实验搭建总结出来的文档