將GitHub上的Repo複製到本地,開新分支處理,上傳新分支資料到GitHub

  1. Clone Github Repo
  2. 建立分支
  3. 處理分支內容
  4. 將異動提到暫存區
  5. 將異動提到本機Repo
  6. 將分支與異動提到Github Repo

 

  1. Clone Github Repo
    xxx@LAPTOP-LIGR7CRV MINGW64 /d/test/blogger
    $ git clone https://github.com/xxx/blogger.git
    
    xxx@LAPTOP-LIGR7CRV MINGW64 /d/test/blogger
    $ cd blogger
    
    xxx@LAPTOP-LIGR7CRV MINGW64 /d/test/blogger/blogger (master)
    

    進入clone回來的路徑下,自動進入master分支中

  2. 建立分支
    xxx@LAPTOP-LIGR7CRV MINGW64 /d/test/blogger/blogger (master)
    $ git checkout -b sqlite
    Switched to a new branch 'sqlite'
    
    xxx@LAPTOP-LIGR7CRV MINGW64 /d/test/blogger/blogger (sqlite)
    

     

  3. 處理分支內容
    建立一個 readme.md 檔案
     
  4. 將異動提到暫存區
    xxx@LAPTOP-LIGR7CRV MINGW64 /d/test/blogger/blogger (sqlite)
    $ git status
    On branch sqlite
    Untracked files:
      (use "git add <file>..." to include in what will be committed)
    
            readme.md
    
    nothing added to commit but untracked files present (use "git add" to track)
    
    xxx@LAPTOP-LIGR7CRV MINGW64 /d/test/blogger/blogger (sqlite)
    $ git add .
    
    xxx@LAPTOP-LIGR7CRV MINGW64 /d/test/blogger/blogger (sqlite)
    $ git status
    On branch sqlite
    Changes to be committed:
      (use "git reset HEAD <file>..." to unstage)
    
            new file:   readme.md
    
    

     

  5. 將異動提到本機Repo
    xxx@LAPTOP-LIGR7CRV MINGW64 /d/test/blogger/blogger (sqlite)
    $ git commit -m 'add readme.md'
    [sqlite f0be20e] add readme.md
     1 file changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 readme.md
    

     

  6. 將分支與異動提到Github Repo
    xxx@LAPTOP-LIGR7CRV MINGW64 /d/test/blogger/blogger (sqlite)
    $ git push origin sqlite
    Enumerating objects: 3, done.
    Counting objects: 100% (3/3), done.
    Delta compression using up to 8 threads
    Compressing objects: 100% (2/2), done.
    Writing objects: 100% (2/2), 258 bytes | 258.00 KiB/s, done.
    Total 2 (delta 1), reused 0 (delta 0)
    remote: Resolving deltas: 100% (1/1), completed with 1 local object.
    remote:
    remote: Create a pull request for 'sqlite' on GitHub by visiting:
    remote:      https://github.com/xxx/blogger/pull/new/sqlite
    remote:
    To https://github.com/xxx/blogger.git
     * [new branch]      sqlite -> sqlite