20 lệnh Git hữu ích mọi lập trình viên nên biết
Git là công cụ quản lý phiên bản không thể thiếu trong lập trình, giúp theo dõi và quản lý thay đổi trong mã nguồn của các dự án.
https://about.gitlab.com/images/press/git-cheat-sheet.pdf
https://education.github.com/git-cheat-sheet-education.pdf1. Thiết Lập Cấu Hình Toàn Cầu
git config --global user.name "Tên của bạn"
git config --global user.email "[email protected]"usage: git config [<options>]
Config file location
--[no-]global use global config file
--[no-]system use system config file
--[no-]local use repository config file
--[no-]worktree use per-worktree config file
-f, --[no-]file <file>
use given config file
--[no-]blob <blob-id> read config from given blob object
Action
--[no-]get get value: name [value-pattern]
--[no-]get-all get all values: key [value-pattern]
--[no-]get-regexp get values for regexp: name-regex [value-pattern]
--[no-]get-urlmatch get value specific for the URL: section[.var] URL
--[no-]replace-all replace all matching variables: name value [value-pattern]
--[no-]add add a new variable: name value
--[no-]unset remove a variable: name [value-pattern]
--[no-]unset-all remove all matches: name [value-pattern]
--[no-]rename-section rename section: old-name new-name
--[no-]remove-section remove a section: name
-l, --[no-]list list all
--[no-]fixed-value use string equality when comparing values to 'value-pattern'
-e, --[no-]edit open an editor
--[no-]get-color find the color configured: slot [default]
--[no-]get-colorbool find the color setting: slot [stdout-is-tty]
Type
-t, --[no-]type <type>
value is given this type
--bool value is "true" or "false"
--int value is decimal number
--bool-or-int value is --bool or --int
--bool-or-str value is --bool or string
--path value is a path (file or directory name)
--expiry-date value is an expiry date
Other
-z, --[no-]null terminate values with NUL byte
--[no-]name-only show variable names only
--[no-]includes respect include directives on lookup
--[no-]show-origin show origin of config (file, standard input, blob, command line)
--[no-]show-scope show scope of config (worktree, local, global, system, command)
--[no-]default <value>
with --get, use default value when missing entry
--[no-]comment <value>
human-readable comment string (# will be prepended as needed)2. Hoàn Tác Commit Cuối (Không Mất Thay Đổi)
3. Chỉnh Sửa Commit Cuối
4. Lưu Trữ Tạm Thời Các Thay Đổi Chưa Commit
5. Xem Lịch Sử Commit Dưới Dạng Đồ Họa
6. Thay Đổi Tác Giả Của Commit
7. Kiểm Tra Sự Khác Biệt Của Các Thay Đổi Đã Staged
8. Tìm Bug Bằng Bisect
9. Rebase Để Làm Sạch Lịch Sử Commit
10. Cherry-Pick Commit Cụ Thể
11. Liệt Kê Tất Cả Các Nhánh (Local Và Remote)
12. Xóa Các Tệp và Thư Mục Không Được Theo Dõi
13. Theo Dõi Một Nhánh Upstream
14. Gộp Commit Bằng Rebase Tương Tác
15. Xem Tệp Tại Một Commit Cụ Thể
16. Chỉnh Sửa .gitignore Sau Khi Commit
.gitignore Sau Khi Commit17. Hoàn Tác Một Commit Đã Đẩy Lên
18. Fetch Chỉ Metadata
19. Blame Một Dòng Code
20. Reset Một Tệp Về Commit Cuối Cùng
Kết Luận
PreviousHướng Dẫn Nhanh về Các Lệnh Git Cơ BảnNextCách tối ưu hóa kích thước thư mục .git để cải thiện hiệu suất
Last updated