接着上文《Git 基础 - 克隆远程仓库到本地,修改后推送到远程》:
[@wooluwalkerdeMacBook-Pro:wenjian (dev)]$ git checkout -b dev origin/dev #在本地创建并切换到dev分支,并连接到远程的dev分支 [@wooluwalkerdeMacBook-Pro:wenjian (dev)]$ git pull origin dev #在本地dev分支拉取远程dev分支 [@wooluwalkerdeMacBook-Pro:wenjian (dev)]$ ll # 远程dev分支内容已经pull下来 total 16 drwxr-xr-x 10 walker staff 320B 2 2 12:59 . drwxr-xr-x 6 walker staff 192B 2 2 12:38 .. -rw-r--r-- 1 walker staff 6.0K 2 2 12:59 .DS_Store drwxr-xr-x 15 walker staff 480B 2 2 13:02 .git -rw-r--r-- 1 walker staff 0B 2 2 12:59 README.md -rw-r--r-- 1 walker staff 0B 2 2 12:59 __init__.py drwxr-xr-x 7 walker staff 224B 2 2 12:59 __pycache__ drwxr-xr-x 9 walker staff 288B 2 2 12:59 data drwxr-xr-x 6 walker staff 192B 2 2 12:59 merge drwxr-xr-x 8 walker staff 256B 2 2 12:59 utils [@wooluwalkerdeMacBook-Pro:wenjian (dev)]$ git checkout master [@wooluwalkerdeMacBook-Pro:wenjian (master)]$ ll # master分支并没有dev分支的内容 total 8 drwxr-xr-x 4 walker staff 128B 2 2 13:04 . drwxr-xr-x 6 walker staff 192B 2 2 12:38 .. drwxr-xr-x 15 walker staff 480B 2 2 13:04 .git -rw-r--r-- 1 walker staff 34B 2 2 13:04 README.md [@wooluwalkerdeMacBook-Pro:wenjian (master)]$ git merge dev #将本地dev分支合并到本地master分支 [@wooluwalkerdeMacBook-Pro:wenjian (master)]$ git status #本地master分支比远程master分支提前 On branch master Your branch is ahead of 'origin/master' by 4 commits. (use "git push" to publish your local commits) [@wooluwalkerdeMacBook-Pro:wenjian (master)]$ git push # 将本地master分支推送到远程master分支,在web页面可看到远程master分支上有了新增内容