步驟1
創建並切換到新的「開發」分支,您的本地git文件與遠程同步,但「dev」分支尚不存在。
git branch dev # create
git checkout dev # switch
# No need to git add or git commit, the current
# branch's files will be cloned to the new branch by-default.
git push --set-upstream origin dev # push the "dev" branch to the remote.
步驟2
進行更改的「開發」分支(當前的,如果你遵循步驟1),提交併推送到遠程的「開發」分支。
git add .
git commit -S -m "my first commit to the dev branch" # remove the -S if you're not "secure", secure = when you already setup crypto private and public keys (i.e "verified" green sign in github)
git push -u origin dev # push the changes to the remote, -u origin dev is optional but good to use.
步驟3
合併的 「開發」 分支到 「主人」。
git checkout dev # switch to "dev" branch if you're not already.
git merge master # optionally, this command is being used to resolve any conflicts if you pushed any changes to your "master" but "dev" doesn't have that commit.
git checkout master # switch to "master", which is the branch you want to be merged.
git merge --no-ff dev # merge the "dev" branch into the "master" one.
'git pull -u'設置分支的上游跟蹤(如果推送多個分支,則爲所有分支)。一旦設置,跟蹤依然存在。沒有理由不斷使用它。 –
@YoushaAleayoub爲什麼呢? – Lukon
不錯的工作...保存我的時間。 –