Git basic
Loi Mai
Digital ConsultantUse the following commands sync your changes to GitHub.
- Stage all changed files:
git add .
- Commit all changes
git commit -m "Update build config"
- Push your changes to GitHub.
git push origin master
Kiểm tra trạng thái thay đổi
git status
Nếu sử dụng Github bằng giao thức HTTPS thì mỗi lần push sẽ yêu cầu nhập usernam và password, để hạn chế nhập nhiều lần có thể sử dụng cách sau:
$ git config --global credential.helper 'cache --timeout=3600'
# Set the cache to timeout after 1 hour (setting is in seconds)
Generating a new SSH key
Open Terminal.
Paste the text below, substituting in your GitHub email address.
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Kiểm tra kết nối SSH
ssh -T git@github.com
Switching remote URLs Kiểm tra
git remote -v
SSH to HTTPS
git remote set-url origin https://github.com/USERNAME/REPOSITORY.git
HTTPS to SSH
git remote set-url origin git@github.com:USERNAME/REPOSITORY.git