Git Tutorial
Start a git project
git init
初始化
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
git clone
複製下載
git clone <網址>
About git remote
git push & pull
上傳/下載 遠端
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
About git commit
git add
增加檔案到暫存區
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
git rm
從暫存區移除檔案
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
git log
顯示提交變更
git status
顯示變更檔案的狀態
git commit
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
git revert
移除 commit,在需要移除的 commit 按右鍵
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
About git branch
git switch
切換分支
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
git branch
建立分支
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
git merge
分支合併
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
merge 種類
- merge (fast-forward merge)
預設 merge 選項,會將兩分支的 commit 按時間戳記排序並整合成同分支
- merge without fast-forwarding
會保留兩分支的 commit ,並新增 merge 的 commit 在合成分支上
git tag
建立標籤
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
git for vscode
github ssh setting
-
輸入 ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
成功後會顯示
之後就是輸入兩次密碼
-
輸入 cat ~/.ssh/id_rsa.pub
-
複製整串印出來的東西
-
到 github/gitlab 網站
- github
- settings->SSH and GPG kyes
- 按 New ssh key
- 在 key 貼上複製的東西
- add SSH key
- gitlab
- Edit profile
- SSH keys
- 按 Add new key
- 在 key 貼上複製的東西
- Add key
-
測試
輸入 ssh -T git@gitlab.com
,應該會顯示
github/gitlab auto login setting
-
開啟 git bash terminal
- 在 terminal 右手邊 加號右邊的向下箭頭
- 點
git bash
-
輸入 eval "$(ssh-agent -s)"
-
ssh-add ~/.ssh/id_rsa
設定預設帳號
git config --global user.name "USER_NAME"
git config --global user.email johndoe@example.com