1. Git 遠程倉庫
(1) SSH連接
- 生成公鑰:
ssh-keygen -t rsa -b 4096 -C 你的郵箱,三次回車 - 打印公鑰內容:
cat ~/.ssh/id_rsa.pub - 在GitHub里 -> Settings -> SSH and GPG keys -> 加入生成好的公鑰
- ssh連接:
ssh -T git@github.com
(2) Push
git push <遠程主機名> <本地分支名>:<遠程分支名>
a. 已有遠程倉庫
git clone ssh地址- 更新后commit,然后push
git push -u origin master
b. 新建遠程倉庫
- 在GitHub上新建repo,注意千萬不要Initialize.
(i) 已有本地倉庫 git remote add origin ssh地址git branch -M master-
git push -u origin master
(i) 新建本地倉庫 echo "# test" >> README.mdgit initgit add README.mdgit commit -m "first commit"git branch -M mastergit remote add origin ssh地址git push -u origin master
c. 上傳其他分支
- 先切換到本地要上傳的分支:
git branch 分支1 git push -u origin 要上傳到的分支
d. 上傳到另外的遠程倉庫
git remote add repo2 ssh地址git push -u repo2 要上傳到的分支
e. 強制push
git push -u origin master -f
(3) 刪除遠程倉庫分支
git push origin -d [branch_name]
(4) 刪除本地的遠程倉庫鏈接
git remote remove origin
(5) Clone
git clone ssh地址/https地址- 下載指定分支:
git clone ssh地址/https地址 -b [branch_name] - 下載到指定目錄:
git clone ssh地址/https地址 指定目錄 - 下載到當前目錄
git clone ssh地址/https地址 指定目錄 .
(6) Alias
- 在用戶目錄生成 .bashrc文件:
touch ~/.bashrc - 打開.bashrc編輯:
code ~/.bashrc - 編輯設定簡寫,如:
alias ga='git add' - 重啟bash或
source ~/.bashrc - 設置好看的log格式
alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
(7) Stash
- 臨時儲存文件:
git stash 文件 - 彈出文件:
git stash pop
2. 用VSCode寫markdown
- 下載插件markdown all in one
-
ctrl + shift + p-> 輸入markdown preview -> 側邊預覽