美文网首页
git 合并分支

git 合并分支

作者: 杜宁依果 | 来源:发表于2021-04-20 12:15 被阅读0次

1.首先将代码提交到自己的分支上面,例div1

注意事项

  • 如果是多人开发需要先从远程主分支上面将代码pull下来,如果是一个人开发,那就不需要
git pull origin master //从远程主分支上面将代码pull下来
git status //查看状态
git  add .  //添加代码到本地仓库
git  commit -m '备注信息'  //添加提交备注信息
git  push -u origin div1  //将本地仓库代码提交到远程仓库

2.切换分支到需要合并的分支,例master

git  merge dev1  //

查看状态
$ git status
On branch master
Your branch is ahead of 'origin/master' by 41 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean
上面的意思就是你有41个commit,需要push到远程master上 

3将代码提交到远程仓库

git push origin master

其他命令

更新远程分支列表
git remote update origin --prune

查看所有分支
git branch -a

删除远程分支div1
git push origin --delete div1

删除本地分支 div1
git branch -d  div1

相关文章

网友评论

      本文标题:git 合并分支

      本文链接:https://www.haomeiwen.com/subject/ebtnlltx.html