您的位置:首页 > 编程语言 > C语言/C++

[C++_Windows]Git 的文件目录结构

2013-11-02 12:15 525 查看

Git 的目录结构

|   COMMIT_EDITMSG
|   config
|   description
|   FETCH_HEAD
|   HEAD
|   index
|   ORIG_HEAD
|
+---hooks
+---info
+---logs
+---objects
\---refs


Windows 7 的一个.git目录

|   COMMIT_EDITMSG
|   config
|   description
|   FETCH_HEAD
|   HEAD
|   index
|   ORIG_HEAD
|
+---hooks
|       applypatch-msg.sample
|       commit-msg.sample
|       post-commit.sample
|       post-receive.sample
|       post-update.sample
|       pre-applypatch.sample
|       pre-commit.sample
|       pre-push.sample
|       pre-rebase.sample
|       prepare-commit-msg.sample
|       update.sample
|
+---info
|       exclude
|
+---logs
|   |   HEAD
|   |
|   \---refs
|       +---heads
|       |       master
|       |
|       \---remotes
|           \---calculator
|                   master
|
+---objects
|   +---0a
|   |       fac5bb16e359e4c7c48215174acb95603caf91
|   |
|   +---0c
|   |       51a260b502f7ce56785ee8285bb7de6f7338de
|   |       d202abc49b40c063137682a94a86741a45c9b1
|   |
|   +---13
|   |       05ed0068684e82dda3bcf54feae5220410027e
|   |
|   +---15
|   |       144f67033d5a011fe3f88b01756c9994e86aaa
|   |
|   +---2a
|   |       d6a9c28aac8f0b1450eb198878d495bb194b2d
|   |
|   +---3b
|   |       b141109d2035b1a4c34c72560a5dafd4c8d18b
|   |
|   +---3e
|   |       d57e07da31e92e30127da4d9df8adfa998362a
|   |
|   +---42
|   |       f61fbda25ea8043083fb5230ae0f5cfa70767d
|   |
|   +---47
|   |       1a6f84f2d1eac9c9f5cff3e1557facb86416dd
|   |
|   +---49
|   |       75361772d7205b7892acb02ccb913435b83903
|   |
|   +---52
|   |       a8fa648621dfcea471b5899b149f7d7a275cf4
|   |
|   +---53
|   |       46c4867f9dce6beb804668542351fd92d1b0f8
|   |
|   +---54
|   |       5aca4191524b54036a79d58e8cf6b40af6dc3a
|   |
|   +---55
|   |       20f4c21e78f5884993e6f541354c7484dd5629
|   |       a35ca943ed4a1face7b21a72cc7195b70f9705
|   |
|   +---5a
|   |       45c40b38aefa65b3dd7a4591f10af3fd219c2b
|   |
|   +---62
|   |       0d3dc8a49200fcfae26619eb8a01741fcc41c5
|   |       fd527079ab6de83f472f548cd881f1828413f7
|   |
|   +---70
|   |       17f5c0730c037de15fb0d5bec070c59306fcda
|   |
|   +---73
|   |       9249895e7a5cfa849fb2ecca43450c2907eea0
|   |
|   +---77
|   |       28bd55d93b2065f3faaf23d4312a888a85810e
|   |
|   +---82
|   |       45b761a657412b79560e7b6c01fe7ba8af30cb
|   |
|   +---85
|   |       39f8328bb2c6cf56f9e61ebf31e30148e5c3eb
|   |
|   +---91
|   |       2a7032b2bcac286942909e76c0655310c484e0
|   |
|   +---95
|   |       97b42ae1fe46c252d7a6d843bd2068a2628265
|   |
|   +---96
|   |       a525d689fcf2aeb6ad3e625d0a91e80d85510f
|   |
|   +---9d
|   |       3dee66616115f1de0e1ce1c1bcea7690eeba3e
|   |       48abf7eb509782abca702a6e83d1ac6f6e580b
|   |
|   +---a7
|   |       4b23cae715633addafef0f698e5009dd8660fc
|   |
|   +---ab
|   |       d7fc0b42142c179967641ed57a5f80f8ce2f6c
|   |
|   +---ba
|   |       65c53273fd5193771a9883be29fe32ef06d148
|   |
|   +---be
|   |       e20688b9968d2f0138fea149ef302d3106cbca
|   |
|   +---c1
|   |       e7dac4543d10d8672b31de177be0fbb6a6b425
|   |
|   +---c3
|   |       1e6f7746937292c6967f8131cde1231291a0f7
|   |
|   +---c5
|   |       4f0b6cb4854a33fab6f835c2d85ed54123156d
|   |
|   +---cb
|   |       a2e3d9c04ba70889c447d755e43338d620ab9f
|   |
|   +---cd
|   |       3996ac83c837f88c3e5b26dd4b36e09f91c546
|   |
|   +---d4
|   |       bc43df560b460a71b9ef0ca94cb872efafd1d3
|   |
|   +---d5
|   |       1a3ff269798020514a02f87c8ea7e429e922f1
|   |       6fbcdfdf6eac0f4727c34770c26689271d96af
|   |
|   +---e0
|   |       32aae92a5c8c78ed096f67c3aa2be05c2da6ba
|   |
|   +---e6
|   |       f2f0cf7364253469f2870beafbd6329a77f4b6
|   |
|   +---eb
|   |       e9a18f565103a9c3912e90a9b77d9c246912e3
|   |
|   +---ee
|   |       85cc902747f590535717cc37e152f193ae2051
|   |       c79fa3c0b3113575e5d2e4770d881be1a17476
|   |
|   +---ef
|   |       96536495495776a4b68a5f77674252fa7ed3c2
|   |
|   +---f0
|   |       1a4c11867965aba84754b78a9552a881e6d7a6
|   |
|   +---f1
|   |       0bc7f34ee2b1f32fcfceb8e75a24828598700f
|   |
|   +---fa
|   |       c76315609cb0794ceeec4e7c1320cc3d9281e4
|   |       ce67e36562a6d21f9c95f1a63dd2cff81f8da0
|   |
|   +---info
|   \---pack
\---refs
+---heads
|       master
|
+---remotes
|   \---calculator
|           master
|
\---tags


COMMIT_EDITMSG文件

当Commit时,LOG的信息会被填写在这里。

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch main
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
# modified:   README
#


config

config 文件包含了项目特有的配置选项

[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly
[user]
name = XXX
email = XXX
[merge]
tool = BeyondCompare3
[i18n]
filesEncoding = utf-8
[remote "360"]
url = git@code.csdn.net:XXX
puttykeyfile = C:/Users/XXX/.ssh/XXX
[remote "calculator"]
url = git@code.csdn.net:XXX
fetch = +refs/heads/*:refs/remotes/calculator/*
puttykeyfile = C:/Users/XXX/.ssh/XXX
[branch "master"]
remote = calculator
merge = refs/heads/master


Git的配置具体查看以下Blog
【Git配置技巧】01. 配置文件git config介绍

description

description 文件仅供 GitWeb 程序使用

权威资料访问GitWeb的Wiki或者以下链接
http://sourceforge.net/apps/trac/sourceforge/wiki/GitWeb%20repository%20browser

♢Create a "description" file in your git repository root, with a brief, one-line description of your repository. This file is treated as plain text, any HTML will be escaped. This will appear in the top section of the gitweb repository landing page.

♢Create a "cloneurl" file in your git repository root, containing one url per line. Use this to display the clone url for your repository. This will appear in the same section as the description line, one url per line.

♢Create a "README.html" file in your git repository root, with arbitrary descriptive content. HTML is allowed, and will be displayed inside a div tag on the gitweb page, in a section below the one with description.

♢Set the owner, by setting a gitweb.owner configuration variable in the "config" file, located in your git repository root. If the "gitweb" section does not exist, create it. The owner setting in the config should look like the sample below (you can use any
arbitrary string for owner):

[gitweb]

owner = Your Name <youremail>

References: http://repo.or.cz/w/alt-git.git?a=blob_plain;f=gitweb/README
简言之,

♢在.git目录下创建description文件,内容为一行文本,html格式标记无效

♢在.git目录下创建cloneurl文件,一行一个url

♢在.git目录下的config文件中设置owner,如下:

[gitweb]

owner = Your Name <youremail>

FETCH_HEAD

FETCH_HEAD指的是: 某个branch在服务器上的最新状态.

每一个执行过fetch操作的项目'都会存在一个FETCH_HEAD列表,

这个列表保存在 .git/FETCH_HEAD 文件中, 其中每一行对应于远程服务器的一个分支.

当前分支指向的FETCH_HEAD, 就是这个文件第一行对应的那个分支.

一般来说, 存在两种情况:

♢如果没有显式的指定远程分支, 则远程分支的master将作为默认的FETCH_HEAD.

♢如果指定了远程分支, 就将这个远程分支作为FETCH_HEAD.

常见的git fetch 使用方式包含以下四种:

♢git fetch

这一步其实是执行了两个关键操作:

- 创建并更新所有远程分支的本地远程分支.

- 设定当前分支的FETCH_HEAD为远程服务器的master分支 (上面说的第一种情况)

♢git fetch origin

同上, 只不过手动指定了remote.

♢git fetch origin branch1

设定当前分支的 FETCH_HEAD' 为远程服务器的branch1分支`.

注意: 在这种情况下, 不会在本地创建本地远程分支, 这是因为:

这个操作是git pull origin branch1的第一步, 而对应的pull操作,并不会在本地创建新的branch.

一个附加效果是:

这个命令可以用来测试远程主机的远程分支branch1是否存在, 如果存在, 返回0, 如果不存在, 返回128, 抛出一个异常.

♢git fetch origin branch1:branch2

只要明白了上面的含义, 这个就很简单了,

首先执行上面的fetch操作

使用远程branch1分支在本地创建branch2(但不会切换到该分支),

如果本地不存在branch2分支, 则会自动创建一个新的branch2分支,

如果本地存在branch2分支, 并且是`fast forward', 则自动合并两个分支, 否则, 会阻止以上操作.

git fetch origin :branch2

等价于: git fetch origin master:branch2

HEAD

HEAD文件指向当前分支

ref: refs/heads/master

index

index 文件保存了暂存区域信息。

索引文件(index file)就是.git/index文件,它是二进制形式的文件。我们可以用ls-files来检查它的内容。



git add的作用就是创建一个blob文件来记录最新的修改代码,并且在index file里添加一个到此blob的链接。
git diff会与index文件中的链接目标进行比较
100644表示文件权限(rw_rw_r__)

ORIG_HEAD

当执行git reset命令时,git会把老的HEAD拷贝到文件.git/ORIG_HEAD中,在命令中可以使用ORIG_HEAD引用这个commit。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: