1. 程式人生 > >將原生代碼資料夾作為新分支新增到遠端倉庫

將原生代碼資料夾作為新分支新增到遠端倉庫

將原生代碼資料夾作為新分支新增到遠端倉庫

在windows系統下使用Git,想要將原生代碼資料夾作為新分支新增到遠端倉庫,經過個人實踐,驗證以下操作有效:

1.      在程式碼資料夾右鍵GitBash Here

2.      Git倉庫初始化:  git init

3.      將資料夾中程式碼新增到倉庫: git add .

4.      提交  git Commit  -m “說明”

5.      建立分支 git  branch  Testbranch(該分支是基於master建立的,所以只有做完步驟3、4才可以建立分支)

6.      切換到新建的分之不上 :gitcheckout Testbranch

7.      新增遠端倉庫連結:

執行 git remote add <shortname> <url> 新增一個新的遠端 Git 倉庫,同時指定一個你可以輕鬆引用的簡寫(

pb):

$ git remote

origin

$ git remote addpb https://github.com/paulboone/ticgit

$ git remote -v

origin      https://github.com/schacon/ticgit (fetch)

origin      https://github.com/schacon/ticgit (push)

pb           https://github.com/paulboone/ticgit (fetch)

pb           https://github.com/paulboone/ticgit (push)

                                                            

8.      gitpush  - -set-upstream pb Testbranch(遠端倉庫分支與本地同名)

此時可以在遠端倉庫看到新的分之 Testbranch。