Initializing Git For Version Control

Steven Wang
2 min readMar 5, 2022

--

進入工作目錄及虛擬環境

$ git config --global user.name "Your Name"
$ git config --global user.email "you@youraddress.com"
$ git config --global push.default matching
$ git config --global alias.co checkout
$ git init

https://codemy.com/git

根目錄產製.ssh資料夾及ssh key

根目錄
mkdir .ssh 創建隱藏資料夾ssh
ssh-keygen -t rsa

取得公鑰 與 私鑰

cat id_rsa.pub公鑰

Github set ssh key

github > account > settings > SSH and GPG keys > New SSH key

cat id_rsa.pub
value copy and paste

Github create a new repository and push

github > account > your repository

…or create a new repository on the command line

echo "# stockprg_vix" >> README.md
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/ka666wang/stockprg_vix.git
git push -u origin main

…or push an existing repository from the command line

git remote add origin https://github.com/ka666wang/stockprg_vix.git
git branch -M main
git push -u origin main

not want to push to github

例如 virtual environment stuff 不放入github

touch .gitignore 創建.gitignore

編輯.gitignore

.gitignore 指自己 檔案類
foldername/ 資料夾類
/foldername
flodername

Git初始後的日常作業

git add .
git commit -am “message”
git push

刪除git內資料夾

git rm -r — cached foldername

--

--

Steven Wang
Steven Wang

No responses yet