# Notes:Git Branch Switch & Clone ## 如何更新 git 專案 ### 〔Step 0〕Clone(只有第一次抓專案才做) ```cmd= # 將專案拉至本機 git clone <url> ``` ### 〔Step 1〕Branch 新建並切去新分支 ```cmd= # 新建分支 git branch dev_song # 檢視當前有什麼分支 git branch # 切去分支 git checkout dev_song ``` ### 〔Step 2〕... 開始開發專案,修改程式。 ### 〔Step 3〕Add & Push 更新並推上專案 ```cmd= # 新增修改檔案 git add . # 將修改檔案 commit git commit -m "Update Messages" # 把該分支的檔案 push 上遠端 git push origin dev_song ``` ### 〔Step 4〕Pull Request & Merge 在 GitHub 操作 上去 Github 提出 pull request 等待 merge。 --- ### 〔Step 5〕Pull & Delete 拉下主線並刪除原分支 等到 Github 上支線 merge 之後,就算是完成更新專案的步驟了,後續要重新繼續開發的話,記得先切到主線上,把主線資料拉下來後,刪除本機上原有的分支。如果要繼續開發,一定要回到 [Step 1](#〔Step-1〕Branch-新建並切去新分支) 新建分支後才能開始更改。 ```cmd= # Switched to branch 'main' 回到主線 git checkout main # 把主線新檔案重新抓下來 git pull origin main # 刪除剛才使用完的分支 git branch -d dev_song ``` passwords 可以直接去 github 上的 user settings 上的 developer settings 創建新的 token(開啟全部權限)。 詳細參考這篇:[Git 報錯與 Personal Access Token 創建](/XbL3FPKKSbmY0sbXbNbAiw) --- ### 〔Reference〕從零開始新增專案的流程 可以參考:https://zlargon.gitbooks.io/git-tutorial/content/remote/new_project.html --- : : 20211219 : : 與松 withhhsong : : ###### tags: `withhhsong` `git` `notes` `github`
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.