Open mvn-thaile-dn opened 6 years ago
$ git init Tạo 1 local repository
$ git init
$ git clone <remote-repository-url> Sao chép repository có sẵn về local
$ git clone <remote-repository-url>
$ git remote add <name> <repository-url> Điều khiển remote repository dưới local
$ git remote add <name> <repository-url>
git checkout -b <name_branch>
git checkout <name_branch>
git branch -D <name_branch>
git push origin <name_branch>
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
git fetch -p
git branch -r
git checkout <branch_name>
git log : xem lịch sử commit chi tiết
git log
git log --pretty=oneline : xem lịch sử commit ngắn gọn
git log --pretty=oneline
git commit --amend -m <message> Xóa bỏ lần commit trước và undo commit để commit lại
git commit --amend -m <message>
git reset HEAD introduce.txt Loại bỏ file khỏi staging area
git reset HEAD introduce.txt
Vào nhánh master , sửa đổi file introduct.txt và commit lại
Vào nhánh develop sửa đổi file introduct.txt và commit lại
Trở lại nhánh master và merge nhánh develop vào nhánh master
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
Sửa thành
commit lại , xung đột đã được giải quyết
Bài tập Git
Git init
$ git init
Tạo 1 local repositorygit clone
$ git clone <remote-repository-url>
Sao chép repository có sẵn về localgit remote add
$ git remote add <name> <repository-url>
Điều khiển remote repository dưới localBranch
Tạo 1 nhánh
git checkout -b <name_branch>
Chuyển nhánh
git checkout <name_branch>
Xóa nhánh
git branch -D <name_branch>
Đẩy nhánh lên remote repository
git push origin <name_branch>
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 remotegit checkout <branch_name>
: chuyển sang nhánh mớiMột số lệnh khác
git log
git log
: xem lịch sử commit chi tiếtgit log --pretty=oneline
: xem lịch sử commit ngắn gọngit commit --amend
git commit --amend -m <message>
Xóa bỏ lần commit trước và undo commit để commit lạigit reset HEAD
git reset HEAD introduce.txt
Loại bỏ file khỏi staging areaTạo conflict và sửa conflict
Tạo conflict
Vào nhánh master , sửa đổi file introduct.txt và commit lại
![conf4](https://user-images.githubusercontent.com/40163299/41643165-b2397240-7494-11e8-911d-454b49e32fe2.png)
Vào nhánh develop sửa đổi file introduct.txt và commit lại
Trở lại nhánh master và merge nhánh develop vào nhánh master![conf7](https://user-images.githubusercontent.com/40163299/41643138-a1e14e9a-7494-11e8-9763-929a1f9efc04.png)
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](https://user-images.githubusercontent.com/40163299/41643381-330da904-7495-11e8-8f6b-ed076dfa1bed.png)
Sửa thành![conf9](https://user-images.githubusercontent.com/40163299/41643391-393a3202-7495-11e8-9a8f-59d454e38029.png)
commit lại , xung đột đã được giải quyết![dfd](https://user-images.githubusercontent.com/40163299/41643447-627df69e-7495-11e8-938f-737edc3b7331.png)