新建一个分支的流程
1、新建文件夹xxxx_dev,clone数据
git clone https://xxxxx.git
username
password
2、切换到一个新分支'dev'
git checkout -b dev
Switched to a new branch 'dev'
4、把新建的分支push到远端
git push origin dev
5、关联分支
现在git push会要求填写remote branch,提示如下
λ git pull
Username for 'xxxx':
Password for 'xxxx':
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> dev
如果不想的话,这样关联一下
git branch --set-upstream-to=origin/dev
后面git pull/git push都到dev分支了
6、其他人使用分支
#先更新,再切换分支到dev
git pull
git checkout dev
#然后就看到这个dev的分支了
λ git branch --list
* dev
master
7、git merge
如果要合并master分支的内容
#先切换回master,比如这里被告知有1此的更新
λ git checkout master
Switched to branch 'master'
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
(use "git pull" to update your local branch)
2 files changed, 2 insertions(+), 2 deletions(-)
#更新master的内容
λ git pull
Username for 'xxxxx': xxxx
Password for 'xxxxx':
Updating xxxxx..xxxxx
Fast-forward
Dockerfile | 2 +-
config/uat/nginx.conf | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
# 切换回dev环境
λ git checkout dev
Switched to branch 'dev'
Your branch is up to date with 'origin/dev'.
# 然后merge master的内容
λ git merge master
Merge made by the 'recursive' strategy.
Dockerfile | 2 +-
config/uat/nginx.conf | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
# 最后提交
git push