21
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

git objectを勉強するためのgit-object-trainerコマンド

Last updated at Posted at 2016-08-13

git-object-trainerはgit objectを勉強するためのコマンドです。

git-object-trainerはあなたに磁器(porcelain)コマンド(add, commit, show, diff, checkout, tag, log, diff)の利用を禁止します。それらの代わりに配管(plumbing)コマンド(hash-object, cat-file, update-index, write-tree)を使うことを強制します。

git addなどを入力するとgit-object-trainerはどのようにgit addを配管コマンドで実現すれば良いのかを教えてくれます。

使い方

インストール

go get -u github.com/sonatard/git-object-trainer/

設定

.bash_profileにaliasの設定を追加してください。

.bash_profile
alias git=git-object-trainer

$ git add .
Error: Exec following commands instead of git add

Basic way
# 1. Create . objects
$ git hash-object -w .
[FILE-HASH-STRING]
# 3. Check created object
$ git cat-file -p [FILE-HASH-STRING]
[FILE STRINGS]
# 4. Add or update file to staging area
## 4.1 add
$ git update-index --add --cacheinfo 10644 [FILE-HASH-STRING] .
## 4.2 update
$ git update-index --cacheinfo 10644 [FILE-HASH-STRING] .
# 5. Create tree
$ git write-tree
[TREE-HASH-STRING]
Remember [TREE-HASH-STRING] for commit
# 6. Check tree object
$ git cat-file -p [TREE-HASH-STRING]
[PERMISSION] blob [HASH] .

Easy way. You need not to remember [FILE-HASH-STRING]
# 1. Create tree
$ git write-tree
[TREE-HASH-STRING]
Remember [TREE-HASH-STRING] for commit
# 2. Add or update file to staging area
## 4.1 add
$ git update-index --add .
## 4.2 update
$ git update-index  .
# 6. Check tree object
$ git cat-file -p [TREE-HASH-STRING]
[PERMISSION] blob [HASH] .

ジョークソフトですが、PRお待ちしています。現在引数周りの処理が適当です。

また現在packには未対応です。

ちなみに私は配管コマンドでadd,commit,checkoutはできるようになりました :smiley:

21
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
21
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?