mvn-quangtran-dn / GIT-PHP

0 stars 0 forks source link

G1_Le_QuangThai #12

Open mvn-thaile-dn opened 6 years ago

mvn-thaile-dn commented 6 years ago

Bài tập Git

Git init

$ git init Tạo 1 local repository gitinit

git clone

$ git clone <remote-repository-url> Sao chép repository có sẵn về local

git remote add

$ git remote add <name> <repository-url> Điều khiển remote repository dưới local gitremote

Branch

Tạo 1 nhánh

git checkout -b <name_branch> taonhanh

Chuyển nhánh

git checkout <name_branch> chuyennhanh

Xóa nhánh

git branch -D <name_branch> xoanhanh

Đẩy nhánh lên remote repository

git push origin <name_branch> pushnhanhlen

Kéo nhánh từ remote repository về local

git fetch -p : 'Kéo các nhánh về' git branch -r : Xem các nhánh trên remote git checkout <branch_name> : chuyển sang nhánh mới

fetchnhanh

Một số lệnh khác

git log

git log : xem lịch sử commit chi tiết

gitlog

git log --pretty=oneline : xem lịch sử commit ngắn gọn

gitlogoneline

git commit --amend

git commit --amend -m <message> Xóa bỏ lần commit trước và undo commit để commit lại gitamend

git reset HEAD

git reset HEAD introduce.txt Loại bỏ file khỏi staging area

gitreset2

Tạo conflict và sửa conflict

Tạo conflict

Vào nhánh master , sửa đổi file introduct.txt và commit lại conflict1 conf4

Vào nhánh develop sửa đổi file introduct.txt và commit lại

conflict2 conf6

Trở lại nhánh master và merge nhánh develop vào nhánh master conf7

Conflict xảy ra, ta vào sửa đổi file introduce.txt và quyết định xóa hoặc giữ lại dòng nào rồi conf8

Sửa thành conf9

commit lại , xung đột đã được giải quyết dfd