Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Lệnh học git

I.Trên repository local


1.Tạo repository local
Git init
2.Tạo file trên máy tính(working)
3.Đưa file vào repository local
Git add ten_file or git add . (add tat ca ca file)
Git commit -m “comment”. Sẽ đưa file vào trong
repository local
4.Xóa file trên git local (sau khi commit)
Git rm ten_file
Xóa nhầm thì restore lại: git restore –staged
5.Xóa file sau khi add (untracke)
Git rm –cache ten_file
6.Bỏ qua thư muc, file không muốn add, commit
Tạo file .gitignore và đưa thư muc hay file vào
file .gitignore đấy với cú pháp:
thu_muc/ (bỏ qua thư muc)
Ten_file.txt (bỏ qua file ten_file.txt)
*.txt (bỏ qua tất cả các file .txt)
7.Tạo nhánh
Git branch ten_nhanh
Git branch -l xem nhánh
Git checkout ten_nhanh ( chuyển nhánh)
Git branch -d ten_nhanh (xóa nhánh)
Git merge ten_nhanh (gộp nhánh)

Mở cửa sổ lệnh git bash, chạy lệnh sau để tạo một alias
log: git config --global alias.slog "log --color --graph --
pretty=format:'%Cred%h%Creset -%C(yellow)%d
%Creset %s %Cgreen(%cr) %C(bold blue)<%an>
%Creset' --abbrev-commit" Sau đó chạy lệnh: git slog để
xem log dạng cây.

You might also like