English 中文(简体)
吉唐如何知道哪一个指数会用来补充树木?
原标题:How does Git know which Index blob to add to a tree?
  • 时间:2010-04-27 14:23:44
  •  标签:
  • git

EDIT:如果你回答我的问题,那么就应该说为什么。

http://progit.org/book/ch9-2.html 作者指出:

吉特通常通过利用你的平流区或指数来创造树木,并从中书写树木物体。

我的问题是,如何知道两个组合式指数条目中的制造来自树木的树木物体?

例如(随机编号为40-char SHA1-我刚刚组成):

$ echo  First change  > one.txt
$ git add one.txt 
$ find .git/objects -type f
.git/objects/1f/755a7fffe4   //first index entry

$ echo  Second change  > one.txt
$ git add one.txt
$ find .git/objects -type f
.git/objects/2d/234asdf2   //second index entry

$ git commit -a -m "Initial commit"
$ git cat-file master^{tree}
100644 blob 2d234asdf2 one.txt  //How did it know not to take 1f755??

Does it just look at the blob timestamps? Also - what happens to the first blob created - no one is referencing it. Does it just get destroyed or forgotten?

最佳回答
  1. $ echo  First change  > one.txt
    $ git add one.txt 
    $ find .git/objects -type f
    .git/objects/1f/755a7fffe4...   # first index entry (repository database)
    $ git ls-files --cached --stage --exclude-standard one.txt
    100644 1f755a7fffe4... 0       one.txt   # in  the index 
    
  2. $ echo  Second change  > one.txt
    $ git add one.txt
    $ find .git/objects -type f
    .git/objects/2d/234asdf2...     # second index entry (repository database)
    $ git ls-files --cached --stage --exclude-standard one.txt
    100644 2d234asdf2... 0       one.txt     # in  the index 
    
  3. $ git commit -a -m "Initial commit"
    $ git cat-file -p master^{tree}
    100644 blob 2d234asdf2... one.txt  # the one from  the index 
    
  4. “git gc”将prune (remove) 松散 d物体.git/objects/1f/755a7fffe4.(仅因安全原因推迟)。

问题回答

git从文件.git/index中产生承诺树,该指数储存目前的树种和所有相关信息。 页: 1





相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

热门标签