Các lệnh Git thường dùng
GitHub - GitAlias/gitalias: Git alias commands for faster easier version control
GitHub - initialcommit-com/git-sim: Visually simulate Git operations in your own repos with a single terminal command.
Xem danh sách tất cả commit¶
git log --oneline
git log --oneline --graph
git log --pretty='%C(yellow)%h %C(cyan)%cd%C(auto)%d %Creset%s' --graph --date=relative --date-order
Xem những thay đổi của một commit¶
Xem danh sách tất cả file trong commit mình chọn¶
git ls-tree --name-only -r <commitHash>
git ls-tree --name-only 9dea936:"Tài nguyên hỗ trợ/Công việc thời vụ kiếm tiền nhanh"
- Bỏ
-r
để không recurse
Đọc nội dung một file trong một commit cũ¶
Nếu muốn mở trong vim thì:
Nhược điểm của việc này là vì vim đọc trực tiếp từ stdin, nên không biết định dạng file là gì để mà tô màu. Có thể sửa việc này bằng:
Tìm commit sớm nhất chứa file¶
git log --follow --diff-filter=A --find-renames=40% --pretty=reference -- "**Thông tin cho đại lý.md"
Khởi tạo repo mới và đẩy lên GitHub¶
$repo = 'QuaCau-TheSphere/CA-Bao-hiem'
git init
git add -A
git commit -m "init"
gh repo create --public $repo
$url = gh repo view $repo --json url --jq '.url'
git remote add origin $url
git push -u origin main
Mẹo dùng Git với Obsidian
Xem thêm:: Các lỗi Git thường gặp, Git tag
Xem thêm:: GitHub - git-tips/tips: Most commonly used git tips and tricks.