push 不是備份目前檔案,而是傳送 commit
origin 只是 remote 的慣用名稱。新增 remote 不會立刻上傳任何東西,第一次 push -u 才會傳送 commit 並建立追蹤關係。
git remote add origin https://github.com/demo/git-lab.git
git remote -v
git push -u origin main
git push
git pull
origin/main 是本機記得的遠端 branch 位置,不等於即時讀取 GitHub。git fetch 或 git pull 後,它才會更新。
git clone 則是一個組合動作:下載遠端歷史、建立本機 repository、設定 origin,並取出預設 branch 的檔案。
Windows Credential Manager 與 macOS Keychain 會協助保存認證。不要把 Personal Access Token 寫進 remote URL、程式碼或 commit。
push sends commits; it does not back up your current files
origin is simply the conventional name for a remote. Adding a remote uploads nothing. The first push -u sends commits and creates the tracking relationship.
git remote add origin https://github.com/demo/git-lab.git
git remote -v
git push -u origin main
git push
git pull
origin/main is the remote branch position remembered locally; it is not a live read of GitHub. It updates after git fetch or git pull.
git clone combines several actions: download remote history, create a local repository, set origin, and check out the default branch files.
Windows Credential Manager and macOS Keychain can store credentials. Never put a Personal Access Token in a remote URL, source code, or commit.