Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
352 views
in Technique[技术] by (71.8m points)

git - 从另一个分支在Git中创建一个分支(Create a branch in Git from another branch)

I have two branches: master and dev

(我有两个分支: masterdev)

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

(我想从dev分支创建一个“功能分支”。)

Currently on the branch dev, I do:

(目前在分支机构dev上,我执行以下操作:)

$ 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...

(我的意思是分支似乎在ff合并,我不明白为什么...)

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 .

(像这里描述的那样分支模型中的所有内容。)

  ask by revohsalf translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

(如果您喜欢发布的链接中的方法,请查看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.

(从dev创建MyFeature分支。)

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

Now push changes to the server

(现在将更改推送到服务器)

$ git push origin dev
$ git push origin myFeature

And you'll see it how you want it.

(然后您会看到它想要的样子。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...