从另一个分支在Git中创建一个分支 [英] Create a branch in Git from another branch

查看:132
本文介绍了从另一个分支在Git中创建一个分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个分支: master dev

我想创建一个功能分支 dev 分支。



目前在分支开发中,我这样做:

 $ git checkout -b myfeature dev 

...(某些工作)

  $ git commit -amblablabla
$ git push origin myfeature

但是,在将分支可视化之后,我得到了:
$ b $

   -  ** master ** 
------ 0 ----- 0 ----- 0 ----- 0 ----- 0
------------------------ ** dev ** ---- ** myfeature **



我的意思是分支似乎被合并,我不明白为什么......



我做错了什么?



您能否解释一下我如何从另一个分支分支并推回到功能分支的远程存储库? / p>

分支模型中的所有内容,如这里描述的那个

如果您喜欢发布的链接中的方法,请查看 Git Flow



这是他为该工作流程创建的一组脚本。



但要回答您的问题:

  $ git checkout -b myFeature dev 

创建MyFeature分支off dev。做你的工作,然后

  $ git commit -am您的信息

现在将您的更改合并到开发者而无需快进

  $ git checkout dev 
$ git merge --no-ff myFeature

编辑



现在将更改推送到服务器

  $ git push origin dev 
$ git push origin myFeature

你会看到它你想要什么。


I have two branches: master and dev

I want to create a "feature branch" from the dev branch.

Currently on the branch dev, I do:

$ git checkout -b myfeature dev

... (some work)

$ git commit -am "blablabla"
$ git push origin myfeature

But, after visualizing my branches, I got:

--**master**
------0-----0-----0-----0-----0
------------------------**dev**----**myfeature**

I mean that the branch seems ff merged, and I don't understand why...

What I'm doing wrong?

Can you explain me please how you branch off from another branch and push back to the remote repository for the feature branch?

All that in a branching model like the one described here.

解决方案

If you like the method in the link you've posted, have a look at Git Flow.

It's a set of scripts he created for that workflow.

But to answer your question:

$ git checkout -b myFeature dev

Creates MyFeature branch off dev. Do your work and then

$ git commit -am "Your message"

Now merge your changes to dev without a fast-forward

$ git checkout dev
$ git merge --no-ff myFeature

edit

Now push changes to the server

$ git push origin dev
$ git push origin myFeature

And you'll see it how you want it.

这篇关于从另一个分支在Git中创建一个分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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