GIT development log
Thanks for the great tutorial: https://www.leshenko.net/p/ugit
Thanks again Nikita!
I found some good reference materials, and I put them under the ./doc
directory.
Besides, the follow links maybe help you too.
- Nick Butler this post is short but enough to help you have a higher level to understand diff
- jcoglan this posts make a detail description about the diff.
- visualize if you wanna have a debugger or visualization about diff algorithm, this will be a good choice.
- pdf I also made a short pdf about git, hope you would like it. If you feel interested about this project, you can post your idea on the discussion or just contact me with email.
-
alias zit='java -jar ../zit-1.0-SNAPSHOT-shaded.jar'
alias the zit executable file.- windows could set here
C:\Program Files\Git\etc\profile.d\aliases.sh
- windows could set here
-
zit init
init directory.zit
which includeobjects
subdirectory, init index file which would be treated as stage area, and setmain
branch as default to prevent detached head- the default HEAD file content is
ref: ref/heads/main
- the default HEAD file content is
-
zit hash-object file
- Get the path of the file to store.
- Read the file.
- Hash the content of the file using SHA-1.
- Store the file under
.ugit/objects/{the SHA-1 hash}
.
-
zit cat-file hash [object|tree|commit|...type]
print the file content -
zit write-tree
generate the tree which is the whole description of the repository.- after finished
add
command, it will write tree which is generated by index file
- after finished
-
zit read-tree hash
- pay attention!this action will delete all existing stuff before reading.
- So you can use
cat-file
to find which tree is theroot
, and the logs ofwrite-tree
also help you find all the trees.
-
Although
write-tree
can save version, but it does not take any context information, so will need to developzit commit -m "message"
command.- you can use
cat-file hash commit-id
to check your commit content HEAD
will record your commit with its parent.
- you can use
-
Just enjoy commit and the type
log
to see the logs. -
Now we get the first point:
checkout
. Pick a commit id from thelog
and checkout whether things as expected.- [fixed with getBytes(Charsets.UTF-8)] find bug todo: chinese file or dir name got messy code
- args could be head alias, hash and ref(branch, tags, HEAD...)
-
tag
will alias commit id, and at this time, you will get first inner core concept.- git-ref the official post will help you learn some basic knowledge about the git.
-
todo:
zit lg
graph feature with Graphviz -
zit branch name [id]
so familiar.- Every ref under refs/heads will be treated as a branch.
- file content still just commit id, by default it is the head point
-
zit show
will use diff show changes detail while status only show simply changes info. -
zit add
will add paths which could be file or directory into stage file:.zit/index
. -
zit commit
will callwrite tree
and update head pointer to the commit id.- first time it will create default branch:
main
and will rewrite the HEAD file content to the commit id - the merge HEAD will be deleted and leave the message into commit message
- first time it will create default branch:
-
zit status
this command will tell you what is the situation you are in now.- if you are not detached HEAD, it will log your current HEAD pointed branch first,
- after that, if you are working in merge, it will log the merge hash id,
- then it will log changes to be committed which will diff head tree to index(stage items),
- finally, it will log changes not staged for the next commit which diff index(stage) to work tree.
-
zit diff
the default diff algorithm is myers diff without linear space refinement optimized -
zit reset
just change head to the current commit, the difference between it andcheckout
is the // todo -
zit merge
will check if the merge base equals the head, it will use fast-forward to merge- if fast-forward work, it will be no need to commit
- if not work, we will use diff3 merge to merge the merge base, head tree, other tree
- pay attention: diff3 will leave merge_head in the zit root directory and that means you need to commit manually.
zit merge-base
is used to help the merge command find the first common parent commit of the commits which will be merged. But you also can use this command to do debug task.
-
zit fetch
,zit push
these two combined commands are used to download or upload objects and update the ref.
-
implemented the diff(myers diff but without linear space optimized) and merge algorithms(simple diff3) instead of using unix tools.
-
Ugit
use some coolPythonic
code while zit trying to make code easy understood for the other language developer.
- git hash-object todo. When real Git stores objects it does a few extra things, such as writing the size of the object to the file as well, compressing them and dividing the objects into 256 directories. This is done to avoid having directories with huge number of files, which can hurt performance.