# git ## command line ```command= git config --global user.email "" git config --global user.name "" git status git init git add --all git commit -m "what do you done" git branch -M main git remote add origin https://github.com/lanx06/heroku.git git push -u origin main ``` ## add 儲存 暫存 ### git add . and git add --all #### git add . 只會新增或修改已存在檔案不會刪除 #### git add --all 所有檔案直接同步 如果有刪除檔案則會直接刪除 github上的版本 ## push 上傳 ### 強制上傳 ```command= git push -f origin main ``` ### 更改上傳位置 ```commnd git remote set-url origin https://github.com/USERNAME/OTHERREPOSITORY.git ``` ### 確認上傳位置 ```commnd git remote -v ``` ## pull 同步檔案 ```command git pull origin master ``` ## Clone or download ```command= git clone https://github.com/lanx06/heroku.git ``` ### checkout index ### 放棄檔案變更(回到上次commit 的狀況) ``` git checkout index.py ``` ## branch 分支 我也不熟 ### 分支清單 ``` git branch ``` ### 開啟分支 ``` git branch branch_name ``` ### 合併分支 ``` git merge {new-feature} ``` ### 刪除分支 ``` git branch -d branch_name ``` ## 其他 ### 初始化專案 ``` git init ``` ### 查看狀態 ``` git status ``` ### 檢查差異 ``` git diff ``` ### 將變更檔案放入暫存區 ``` git add index.py ``` ### 使用 commit -m 提交變更 ``` git -a -m 'init commit' ``` ### 查看歷史 ``` git log -- ``` ### 放棄已經 commit 的檔案重回暫存區 ``` git reset HEAD index.py ```