github 的基本用法

上傳到github的新的repository

確認目前狀態

1
>> git status 
再來initialize一個repository
1
>> git init
輸入username和email
1
2
>> git config --global user.name "William Kuo"
>> git config --global user.email "XXX@gmail.com"
新增檔案索引
1
2
>> git add . #新增所有檔案
>> git add 檔案名 #新增單一檔案

寫訊息

1
>> git commit -m "First init commit"
上傳
1
2
3
4
5
6
>> git remote add origin http://github.com/YuWeiKuo/XXX.git

>> git remote add origin git@github.com/YuWeiKuo/XXX.git
#如果打錯,重打
>> git remote rm origin
>> git remote add origin http://github.com/YuWeiKuo/XXX.git
確認狀態(verify),是否有連到github
1
>> git remote -v
確認在哪個branch,顯示現有的分支
1
>> git branch
連結至分支main
1
>> git branch -m main
如果要push到master branch
1
>> git push origin master
如果要push到master main
1
>> git push origin main
切換到main分支
1
>> git checkout main

從github下載

1
>> git clone http://github.com/YuWeiKuo/XXX.io


新增檔案到舊的repository

1
2
3
>> git add 新增的檔案
>> git commit -m "新增檔案"
>> git push -u origin master


刪除repository的檔案

1
2
3
>> git rm 要刪除的檔案
>> git commit -m "刪除檔案"
>> git push -u origin master