本地已有資料,同步到GitHub 新開的 倉庫中
假設專案名稱為 blogger
先在 GitHub 網站上建立倉庫,命名為 blogger
於本機blogger資料夾下,按右滑鼠鍵執行 Git Bash Here
先於blogger 目錄下建一個Git 代碼庫
xxx@NB1602 MINGW64 /d/Test/blogger
$ git init
Initialized empty Git repository in D:/Test/blogger/.git/
檢查目前狀態
xxx@NB1602 MINGW64 /d/Test/blogger (master)
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
.idea/
__pycache__/
blogger/
config.py
run.py
venv/
nothing added to commit but untracked files present (use "git add" to track)
設定Git
xxx@NB1602 MINGW64 /d/Test/blogger (master)
$ git config --global user.name "xxx"
xxx@NB1602 MINGW64 /d/Test/blogger (master)
$ git config --global user.email "xxx@xxx.net"
設定GitHub 的路徑
xxx@NB1602 MINGW64 /d/Test/blogger (master)
$ git remote add blogger "https://github.com/xxx/blogger.git"
將當前目錄整個提交到暫存區Index
xxx@NB1602 MINGW64 /d/Test/blogger (master)
$ git add .
將異動資料提交到本機倉庫
xxx@NB1602 MINGW64 /d/Test/blogger (master)
$ git commit -m "到templates"
將GitHub 上 blogger倉庫中的檔案與本機master分支中的檔案merge
xxx@NB1602 MINGW64 /d/Test/blogger (master)
$ git pull blogger master
強制將本地倉庫中資料傳到GitHub指定倉庫中
xxx@NB1602 MINGW64 /d/Test/blogger (master)
$ git push blogger master --force
Enumerating objects: 770, done.
Counting objects: 100% (770/770), done.
Delta compression using up to 4 threads
Compressing objects: 100% (750/750), done.
Writing objects: 100% (770/770), 9.27 MiB | 599.00 KiB/s, done.
Total 770 (delta 39), reused 0 (delta 0)
remote: Resolving deltas: 100% (39/39), done.
To https://github.com/xxx/blogger.git
+ 8367b8e...0f57249 master -> master (forced update)