GitHub X CCCA X SITCON Talk in NCTU

Look into .git directory

$ git init foo  
$ cd foo  
$ tree  
.  
├── HEAD  
├── config  
├── description  
├── hooks  
│   ├── applypatch-msg.sample  
│   ├── commit-msg.sample  
│   ├── post-update.sample  
│   ├── pre-applypatch.sample  
│   ├── pre-commit.sample  
│   ├── pre-push.sample  
│   ├── pre-rebase.sample  
│   ├── prepare-commit-msg.sample  
│   └── update.sample  
├── info  
│   └── exclude  
├── objects  
│   ├── info  
│   └── pack  
└── refs  
    ├── heads  
    └── tags  
  • refs
    • HEAD, tag, branch
  • objects
    • blob, tree, commit
      • blob
        • type, bytes, content of blob
        • ex: blob 13hello,world
      • tree
        • main file directory for the project
        • tree: point to the next tree object
        • blob: ref name for blob object (one for every related object files for this tree)
      • commit
        • parent: point to the last commit
        • message: commit message
    • store files for git
    • SHA1 hash
    • Compressed
    • commit action will add a commit object and tree object into the objects
    • tree objects have filenames for blob objects
    • blob files which have exactly same content will be stored as the same hash not only in the same project but also among all users.

Branch

  • branch just store the hash of the newest commit for that branch

Tag

  • regular tags do not have hash value
  • be stored in refs/tags
  • just a text file contain the commit object hash
  • annotated tag
    • git tag -a $tag_name
    • tagger, annotation
    • has a hash value

Webhook

Misc

  • if you delete tree objects manually, git fsck will tell you what happened.
  • Git does not support empty directory
  • .gitkeep
  • Every files in Git are treated as binary, so the blob file is not just a plaintext file
  • git clone won't clone unreferenced files in default, but you can specify that.
  • git push/pull won't do anything about unreferenced files
$ watch -n .1 tree  

Git commands

git ls-tree  
git ls-tree HEAD  

git fsck  

git show $tag_name --pretty=raw`  

git rebase $branch  

git reflog  
// use reflog to get the hash or alias and use git reset to undo your actions  

git gc  
// delete useless files (unreferenced files) after 90 days when someone do the action  

Reference


Thoughts

雖然內容大部份在 GitBook 都有
不過真的覺得 Mr.Britton 真的講解得蠻清楚的
比較理解 .git folder 裡面的東西是在做什麼用的
CI 的部分只有提到 Travis CI 在 GitHub 上面的 Webhook
然後 show 一下 GitHub Repo 綁 Traivs CI 後
在 PR 的時候會幫忙跑測試
原本以為會介紹一下 Travis CI 大概要怎麼用
看來得自己找時間研究一下了

然後今天又拿到 Octocat 的新貼紙啦
Octocat
感謝 muan 的這則 Twitter 訊息 才有機會在交大聽到這場 Talk
原來 https://github.com/muan/emoji 是她的 Repo
GitHub 上越來越多 emoji 了XDD


Share


Donation

如果覺得這篇文章對你有幫助, 除了留言讓我知道外, 或許也可以考慮請我喝杯咖啡, 不論金額多寡我都會非常感激且能鼓勵我繼續寫出對你有幫助的文章。

If this blog post happens to be helpful to you, besides of leaving a reply, you may consider buy me a cup of coffee to support me. It would help me write more articles helpful to you in the future and I would really appreciate it.


Related Posts