Git

贰壹叁

Git

build-your-own-x

Gitlet

Git from the inside out - video

Git from the inside out

tree command

tree -a
mkdir
cd

printf 'a' > data/letter.txt

git init

tree .git/objects

git add data/letter.txt

blob file -> .git/objects/2e/65

git cat-file -p 2e65

-> a

cat .git/index
git ls-files -s
git commit -m 'a1'
cat .git/HEAD
cat .git/refs/heads/main
git checkout 1f48 

-> detached HEAD -> check out commit

git checkout main

-> check out branch

git merge branch

-> merge a ancestor(nothing)/descendant(ref/HEAD was changed)
different lineages
Commits can share parents HEAD current branch

git merge main -m 'b4'
git branch -a

Undo Commit

$ git commit -m "Something terribly misguided" # (0: Your Accident)
$ git reset HEAD~                              # (1)
[ edit files as necessary ]                    # (2)
$ git add .                                    # (3)
$ git commit -c ORIG_HEAD                      # (4)
CONFICT
cat .git/index
git ls-files -s 

stage 0 1 2 3... working copy -> git add -> .git/index -> git commit....

To exit git log, type “q” or “z”. Or type “h” to seek for help.

Please enter a commit message...

git rm ...
cd ..
cp -R file_a file_b
 
git remote add file_name path
cat .git/config
git pull repo_name main 
-> git fetch repo_name main
-> cat .git/refs/remotes/repo_name/main
-> tree .git/refs
-> cat .git/FETCH_HEAD
-> git merge FETCH_HEAD -> Fast-forward (merge a descendant)
git clone repo_name repoB_name --bare  -> no working copy
git push repo_A repo_B

看完Git from the inside out - video视频,我对Git的恐惧感减缓了。在一定程度上,Git对我来说不再是一个黑盒子。

可是当我要去实现Gitlet的时候,我恐惧了....
不熟悉不了解的Api、一大串英文、1000+需要理解的代码...
作为对比,我查了一下CS61b用Java实现的Gitlet,光是文档就是万字长文...
恐惧,让我心态失衡和原地踏步。