互聯(lián)網(wǎng)公司必備生存技能之一:GIT(2)

繼上次分享之后,本次主要介紹新分支的創(chuàng)建、切換及合并操作。


五、創(chuàng)建新分支,并推送到遠(yuǎn)程倉庫

1.進(jìn)入本地倉庫,查看當(dāng)前分支:

cd git/test

git branch

2.從master分支上創(chuàng)建新分支并切換到該分支:git checkout -b develop

3. 不放心的話可以用git branch查看一下:

4.將develop分支推送到遠(yuǎn)程倉庫:git push origin develop

完成后,檢查一下github端:

5.在本地新建文件file2,并添加到本地倉庫:

touch file2

git add file2

git commit -m "add file2"

6.推送到遠(yuǎn)程develop分支:git push origin develop

完成后,檢查一下github端:


六、合并master分支到develop分支

1.首先我們在master分支上新建一個文件file3,模擬已經(jīng)上線的代碼:

git checkout master

touch file3

git add file3

git commit -m "add new file3"

git status

git push origin master:master

完成后,檢查一下github端:

2.然后將本地master代碼合并到develop分支:

git checkout develop

git merge master

3.合并完成后推送到遠(yuǎn)程倉庫

git push origin develop

七、合并develop分支到master分支

1.首先我們在develop分支上新建一個文件file4,模擬已經(jīng)提交的新功能代碼:

git checkout develop

touch file4

git add file4

git commit -m“add new file4”

git status

2.將本地develop分支合并到master分支:

git checkout master

git merge develop

3.推送本地分支到遠(yuǎn)程分支:git push origin master:master

4.完成后,檢查一下github端:

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容