如何将当前分支合并到另一个分支 [英] How to merge the current branch into another branch

查看:142
本文介绍了如何将当前分支合并到另一个分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个分支,master和dev。我一直致力于开发,一旦批准生产使用,只能将代码检入主分支。当我这样做时,我必须执行以下操作:

  git checkout master 
git合并开发
git checkout dev

这非常详细,而且我经常这样做,所以我想尽量减少它。是否有任何一个git命令可以用来从我当前的分支机构合并到另一个分支主机,而无需首先检出主分支?可能是这样的:

pre $ git merge dev to master

会很棒。

解决方案

1.添加远程文件

  git remote add self file:/// path / to / your / repository 

(或在窗口 git remote add self C:\path\to\\ \\ your_ \\ repository



2。推到自我远程,例如:

  git push self dev:master 


I have two branches, master and dev. I always work on dev and only check code into the master branch once it's been approved for production use. When I do so, I have to do the following:

git checkout master
git merge dev
git checkout dev

That's awfully verbose, and since I do it frequently, I'd like to minimize it. Is there any one git command I can use to merge from my current branch dev to the other branch master without having to checkout the master branch first? Something maybe like:

git merge dev to master

would be awesome. I looked through the git documentation and didn't see anything.

解决方案

1. Add a remote alias for your local repository, ex:

git remote add self file:///path/to/your/repository

(Or on windows git remote add self C:\path\to\your\repository)

2. Push to the self remote, ex:

git push self dev:master

这篇关于如何将当前分支合并到另一个分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆