Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Git update for Windows

git update-git-for-windows

Khi commit rồi nhưng cần phải thay đổi file

Lệnh này sẽ gộp file trong Staging area với file của commit gần nhất thành 1 commit, có thể thay đổi hoặc giữ nguyên message

git commit --amend

Bỏ bớt file đã add

git reset HEAD <file cần unstage>

ví dụ

git reset HEAD src/controller/auth.controller.ts

Unstage toàn bộ

git reset

Về thao tác Remote repo

Xem tất cả các URL của remote repo

git remote -v

Thêm URL remote repo vào local repo

git remote add origin <url>

Thay đổi URL remote repo

git remote set-url origin <url>

Sao chép remote repo

git clone <url>

Cập nhật local repo

git pull origin <branch>

Về user name và email

Xem user name hoặc email

Cách 1: git config <user.name hoặc user.email>

git config user.name

Cách 2: git config --list

Git graph

git log --oneline --decorate --graph --all

Git stash

git stash giúp bạn "giữ lại" những thay đổi mà bạn đã tạo ra trên local repo nhưng chưa commit, để bạn có thể chuyển branch hay làm công việc gì khác, sau đó bạn có thể áp nó vào lại

git stash

Lưu ý: git stash chỉ stash:

  • Những thay đổi trên file đã được stage (đã được git add)
  • Những thay đổi trên file chưa được stage nhưng đang được quản lí bởi git (chưa git add, nhưng file đã nằm trong repo từ những lần commit trước)

Và sẽ không stash

  • File mới được tạo chưa nằm dưới sự quản lí của git
  • File bị ignore (bởi .gitignore)
git stash pop
# Reapply stash and removes the changes from stash
git stash apply 
# Reapply stash, keeps the changes in stash