I. Mỗi project một tài khoản GIT riêng
- Kiểm tra tài khoản trên máy tính hiện tại:
1 2 3 4 5 |
git config --list # user.name=duycode-com # ... // Có thể xóa tài khoản Git trên window --> Run: "Credential Manager" |
- Cài đặt account GIT riêng : Vào repository/.git/config --> Thêm vào cuối
1 2 3 4 5 |
[user] name = duycode-com email = duycode.com@gmail.com [credential "https://github.com/duycode-com/mern-stack.git"] username = duycode-com |
II. Một số lỗi nhỏ hay gặp
1. Fix lỗi CRLF
1 2 3 4 5 |
git config core.autocrlf false git rm --cached -r . git reset --hard |
2. Thêm file hoặc thư mục vào .gitignore không thành công
- Lý do là file đó đã được theo dõi bởi git
1 2 3 4 5 6 7 8 9 |
// Ví dụ xóa file .env // 1. Xóa theo dõi file bởi git git reset .env // 2. Xóa trên git remote git rm --cached .env git add . git commit -m "update iggnore" git push github master |
- Đơn giản hơn, xóa sạch cache rồi commit lại
1 2 3 4 5 |
git rm -r --cached . // update .gitignore git add . git commit -m "Update .gitignore" git push |