Open ghost opened 6 years ago
git init
Khởi tạo git tại PC. Hình ảnh:
git clone <url-clone>
Lấy một repo về PC của mình. Hình ảnh:
git remove add origin <url>
Thêm origin vào local để push, fetch.
git branch
Show branch hiện tại của repo
git branch <name-branch>
Tạo mới một branch.
git branch -D <name-branch>
Xóa một branch.
git checkout -b <name-branch>
Tạo mới và chuyển đến branch vừa tạo.
git add . \\ Thêm toàn bộ file mới git add <name-file> \\ Thêm một file.
Thêm file vào nhánh local.
git commit -m "<commit content>"
Nội dung commit.
git commit --amend
Chỉnh sửa một file hay thêm file với lần commit trước đó.
git log
Xem lại lịch sử commit.
git diff
Xem nội dung chỉnh sửa trên một nhánh.
git diff <branch-name 1> <branch-name 2>
Xem nội dung chỉnh sửa so với nhánh.
git checkout <file-name>
Khi một file chỉnh sửa mà mình không muốn, thì quay lại trước khi chỉnh sửa.
git reset <reversion>
Dùng git log để xem các reversion trước đó. reset về reversion hiện tại
git revert <commit id>
Quay về với id commit.
git log --oneline
Xem lại lịch sử commit với ID cùng một dòng.
git fetch <origin> <remote-branch-name>
Lấy một nhánh không có trên PC mà có trên repo. Hình ảnh:
git pull <origin> <branch>
Lấy giữ liệu từ một nhánh đã có trên PC.
git push <origin> <branch>
Đưa file lên remote repo.
Những đoạn khác nhau trong một file Sau khi phán đoán người dùng sẽ loại bỏ đoạn văn bản sai
git init
Khởi tạo git tại PC. Hình ảnh:![screenshot from 2018-06-19 15-52-00](https://user-images.githubusercontent.com/40163209/41626155-8ddecc50-7445-11e8-8464-11b5ff0fd288.png)
git clone
Lấy một repo về PC của mình. Hình ảnh:![screenshot from 2018-06-19 15-56-06](https://user-images.githubusercontent.com/40163209/41626276-ebaa5db8-7445-11e8-8714-fec445d118c4.png)
git remote add
Thêm origin vào local để push, fetch.![screenshot from 2018-06-19 15-59-54](https://user-images.githubusercontent.com/40163209/41626406-63535a36-7446-11e8-9b46-7d8f9c20ba58.png)
git branch
Show branch hiện tại của repo![screenshot from 2018-06-20 05-02-52](https://user-images.githubusercontent.com/40163209/41626708-51515a44-7447-11e8-941e-a6a2e68d6d33.png)
Create Branch
Tạo mới một branch.![screenshot from 2018-06-20 05-05-49](https://user-images.githubusercontent.com/40163209/41626776-9c2f65f6-7447-11e8-8dbd-7754aa403ede.png)
delete branch
Xóa một branch.![screenshot from 2018-06-20 05-07-03](https://user-images.githubusercontent.com/40163209/41626813-c941f8f6-7447-11e8-92b8-8d132b7bef6b.png)
git checkout -b name-branch
Tạo mới và chuyển đến branch vừa tạo.![screenshot from 2018-06-20 05-08-46](https://user-images.githubusercontent.com/40163209/41626861-05ff9adc-7448-11e8-89f4-56491fcedcfb.png)
git add
Thêm file vào nhánh local.![screenshot from 2018-06-20 05-10-51](https://user-images.githubusercontent.com/40163209/41626973-8686881e-7448-11e8-8216-ecb45cdcb9c9.png)
git commit
Nội dung commit.![screenshot from 2018-06-20 05-16-53](https://user-images.githubusercontent.com/40163209/41627129-2ad65480-7449-11e8-9a5a-eb4e01d259b9.png)
git commit --amend
Chỉnh sửa một file hay thêm file với lần commit trước đó.![screenshot from 2018-06-20 05-21-48](https://user-images.githubusercontent.com/40163209/41627275-d9d2261c-7449-11e8-9d56-dae4c97ca144.png)
git log
Xem lại lịch sử commit.![screenshot from 2018-06-20 05-23-08](https://user-images.githubusercontent.com/40163209/41627317-0c300070-744a-11e8-99cf-0b08d8241793.png)
git diff
Xem nội dung chỉnh sửa trên một nhánh.![screenshot from 2018-06-20 05-28-07](https://user-images.githubusercontent.com/40163209/41627503-bd7758d8-744a-11e8-801b-4e624b2dd291.png)
Xem nội dung chỉnh sửa so với nhánh.
lệnh checkout 1 file
Khi một file chỉnh sửa mà mình không muốn, thì quay lại trước khi chỉnh sửa.![screenshot from 2018-06-20 05-40-04](https://user-images.githubusercontent.com/40163209/41627901-66d210c0-744c-11e8-98c1-478fc354bc3f.png)
git reset
Dùng git log để xem các reversion trước đó.
reset về reversion hiện tại
![screenshot from 2018-06-25 09-10-24](https://user-images.githubusercontent.com/40163209/41827988-cdd69bb0-785c-11e8-8992-e5046f5e618b.png)
git revert
Quay về với id commit.![screenshot from 2018-06-20 05-50-55](https://user-images.githubusercontent.com/40163209/41628264-ed0ab740-744d-11e8-8bdb-cfb385a42cde.png)
git log --oneline
Xem lại lịch sử commit với ID cùng một dòng.![screenshot from 2018-06-20 05-48-23](https://user-images.githubusercontent.com/40163209/41628171-8efda4fa-744d-11e8-9f9e-eb468f22dcf5.png)
git fetch
Lấy một nhánh không có trên PC mà có trên repo. Hình ảnh:![screenshot from 2018-06-20 05-54-44](https://user-images.githubusercontent.com/40163209/41628379-733cc8f8-744e-11e8-9b9b-488a05a15211.png)
git pull
Lấy giữ liệu từ một nhánh đã có trên PC.![screenshot from 2018-06-20 05-56-25](https://user-images.githubusercontent.com/40163209/41628427-b16b1f12-744e-11e8-8f01-1c101146e7a1.png)
git push
Đưa file lên remote repo.![screenshot from 2018-06-20 06-11-46](https://user-images.githubusercontent.com/40163209/41628912-d752d808-7450-11e8-8b9d-d5138ad2c0c5.png)
Create conflict