Git global setup
git config --global user.name "cruise"
git config --global user.email "cruisecg.cg@gmail.com"
Create a new repository
git clone https://gitlab.3ag.xyz/backend/service.git
cd service
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Push an existing folder
cd existing_folder
git init
git remote add origin https://gitlab.3ag.xyz/backend/service.git
git add .
git commit -m "Initial commit"
git push -u origin master
Push an existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin https://gitlab.3ag.xyz/backend/service.git
git push -u origin --all
git push -u origin --tags
用ssh 取代 https
教學
//可以每次手打
git remote set-url origin git@gitlab.com/...
//globally config (~/.gitconfig) or per-repo (.git/config)
git config url.ssh://git@github.com/.insteadOf https://github.com/
git config url.ssh://git@gitlab.com/.insteadOf https://gitlab.com/
or
git config --global url.ssh://git@github.com/.insteadOf https://github.com/
git config --global url.ssh://git@gitlab.com/.insteadOf https://gitlab.com/
//這幾種格式都試一下
git config url.git@github.com/.insteadOf https://github.com/
git config url.git@github.com:.insteadOf https://github.com/
git config url.ssh://git@github.com:.insteadOf https://github.com/
檔案
檔案狀態
1 untracked commit過後加入的檔案,預設沒有 track
2 tracked 有 track 的檔案,有任何變更,會追蹤
3 unstaged 有追蹤,但是沒有加入預備區(預備提交)
4 staged 有加入預備區
5 uncommitted 在預備區,尚未提交
6 committed 已經提交(push 就會上到 remote repos)
變更檔案狀態
改變檔案狀態,都是使用 add 命令。無論是要 track , stage 檔案,都是 add 。
add 之後,檔案會變成 uncommitted 狀態。
沒有留言:
張貼留言