如何在git的本地分支中获取更改? [英] How to get changes in a local branches in git?

查看:92
本文介绍了如何在git的本地分支中获取更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,目前我正在使用git来管理我的源代码.

Hi Currently I am using git for managing my source code.

我目前有一个master分支和development分支.我通常会从开发创建一个功能分支,对其进行处理,然后合并回开发.

I have currently a master branch and develop branch. i usually creates a feature branch from from develop, works on it and then merge back to develop .

如何获取有关develop分支到其他本地分支的最新更改.

How can i get the latest changes on develop branch to other local branches.

换句话说,如果我有两个特征分支B1和B2都从development检查过.我对B1进行了一些提交,然后合并了B1进行开发.我如何才能将内容从开发分支更改为功能分支B2?

in other words if i have two feature branch B1 and B2 both checked from develop . i did some commits on B1 and then merged B1 to develop . How can i get changes from develop branch to my feature branch B2 ?

谢谢.

推荐答案

,您可以合并变基.

合并

git fetch # make sure origin/develop is up to date
git checkout B2
git merge origin/develop # merge changes from origin/develop into your branch

专业版:

  • 您不需要重写B2历史记录

CONTRA:

  • 您可能需要解决合并提交中的冲突,这使得更难以追溯更改并知道由谁负责.
  • 这会产生更复杂的历史

REBASE

git fetch # make sure origin/develop is up to date
git checkout B2
git rebase origin/develop # rebase your B2 branch on the "new" develop branch

专业版:

  • 您会获得干净的半线性" git历史记录
  • 所有更改都可追溯到单个开发分支.没有属于这两个功能的更改的合并提交

CONTRA:

  • 重写历史记录并不总是直观的
  • 您更改了历史记录,因此,如果其他人在同一分支上工作,则引用也会更改.如果我是分支机构中唯一的工作人员,我认为这样做还可以.如果其他人在分支上工作,则重写历史记录不正确(例如,在 develop master 分支上)
  • rewriting history isn't always intuitive
  • you change your history, so if other people work on the same branch, the references change. I consider this ok if I am the only person working on my branch. If other people work on the branch, rewriting history is NOT OK (eg on develop or master branch)

这篇关于如何在git的本地分支中获取更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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