Open mvn-khanhnguyen-dn opened 6 years ago
Khởi tạo git dưới local git init
git init
Clone repo trên git xuống local git clone {url repo}
git clone {url repo}
git remote add {name} {repo} Thêm remote name với url là repo
git remote add {name} {repo}
git branch Xem các branch đang có
git branch
git branch {name} Tạo branch mới tên name
git branch {name}
git branch -D {name} Xóa branch tên name
git branch -D {name}
git checkout -b {name} Tạo và chuyển sang branch name
git checkout -b {name}
git add ./{file} Thêm 1 hoặc nhiều file đã thay đổi để chuẩn bị commit
git add ./{file}
git commit -m {message} Xác nhận các thay đổi trong file đã add
git commit -m {message}
git commit --amend Sửa đổi commit trước đó
git commit --amend
git log Hiện chi tiết các commit
git log
git diff {file} Xem sự khác nhau của file trước và sau khi sửa
git diff {file}
git diff {branch1} {branch2} So sánh branch1 với branch2
git diff {branch1} {branch2}
git checkout HEAD~{number} {file} Đưa file về trạng thái trước number lần commit
git checkout HEAD~{number} {file}
git reset HEAD~{number} Hủy bỏ number lần commit trước đó
git reset HEAD~{number}
git revert HEAD~{number} Quay lại trạng thái trước number lần commit bằng cách tạo 1 commit mới
git revert HEAD~{number}
git log --oneline Hiện log mỗi lần commit trên 1 dòng
git log --oneline
git fetch origin Lấy file từ branch trên server về branch local
git fetch origin
git pull origin master Lấy và merge nội dung trên repo vào local
git pull origin master
git push origin {branch} Đẩy nội dung đã commit lên branch
git push origin {branch}
git stash orr git stash save {message} Tạo 1 snapshot cho phiên làm việc hiện tại và lưu vào 1 stack
git stash
git stash save {message}
git stash list Liệt kê các stash hiện có trong stack
git stash list
git stash show
git stash show stash@{stash}
git stash apply stash@{n} Lấy lại phiên làm việc n trong stash
git stash apply stash@{n}
git stash pop Quay lại phiên làm việc cuối và xóa nó khỏi stack của stash
git stash pop
git stash drop or git stash drop stash@{n} Xóa stash cuối hoặc stash chỉ định trong stack
git stash drop
git stash drop stash@{n}
git stash clear Xóa tất cả stash
git stash clear
Em đã update issues, cảm ơn anh @at-quangtran đã review giúp em ạ!
GIT group command 1
Git init
Khởi tạo git dưới local![gitinit](https://user-images.githubusercontent.com/40163404/41764022-1427fef4-762a-11e8-8588-4cfd03b310b3.png)
git init
Git clone
Clone repo trên git xuống local![gitclone](https://user-images.githubusercontent.com/40163404/41764109-57192aee-762a-11e8-9840-c7a34687eff2.png)
git clone {url repo}
Git remote add
git remote add {name} {repo}
Thêm remote name với url là repoGit branch
git branch
Xem các branch đang cóGIT group command 2
Create new branch
git branch {name}
Tạo branch mới tên nameDelete branch
git branch -D {name}
Xóa branch tên nameCreate and switch branch
git checkout -b {name}
Tạo và chuyển sang branch nameGit add
git add ./{file}
Thêm 1 hoặc nhiều file đã thay đổi để chuẩn bị commitGit commit
git commit -m {message}
Xác nhận các thay đổi trong file đã addGIT group command 3
Git commit amend
git commit --amend
Sửa đổi commit trước đóGit log
git log
Hiện chi tiết các commitGit diff
git diff {file}
Xem sự khác nhau của file trước và sau khi sửaGit diff branch
git diff {branch1} {branch2}
So sánh branch1 với branch2Git checkout file
git checkout HEAD~{number} {file}
Đưa file về trạng thái trước number lần commitGIT group command 4
Git reset
git reset HEAD~{number}
Hủy bỏ number lần commit trước đóGit revert
git revert HEAD~{number}
Quay lại trạng thái trước number lần commit bằng cách tạo 1 commit mớiGit log oneline
git log --oneline
Hiện log mỗi lần commit trên 1 dòngGIT group command 5
Git fetch
git fetch origin
Lấy file từ branch trên server về branch localGit pull
git pull origin master
Lấy và merge nội dung trên repo vào localGit push
git push origin {branch}
Đẩy nội dung đã commit lên branchGIT group command 6
Create conflict
Solve conflict
GIT group command 7
Git stash
git stash
orrgit stash save {message}
Tạo 1 snapshot cho phiên làm việc hiện tại và lưu vào 1 stackGit stash list
git stash list
Liệt kê các stash hiện có trong stackGit stash show
git stash show
để chỉ ra sự khác nhau giữa phiên hiện tại và stash cuốigit stash show stash@{stash}
để chỉ ra sự khác nhau giữa phiên hiện tại và stash được chỉ địnhGit stash apply
git stash apply stash@{n}
Lấy lại phiên làm việc n trong stashGit stash pop
git stash pop
Quay lại phiên làm việc cuối và xóa nó khỏi stack của stashGit stash drop
git stash drop
orgit stash drop stash@{n}
Xóa stash cuối hoặc stash chỉ định trong stackGit stash clear
git stash clear
Xóa tất cả stash