本文介绍了如何在git中本地合并master和fork?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在Formtastic 2中使用Active_admin,而main分支尚不支持它.

I need to use Active_admin with Formtastic 2 and the main branch doesn't support it yet.

几个星期前,有人用叉子支持Formtastic 2但是随后,其他添加项被添加到master分支中,而未提交到派生分支中.现在,叉子在其他方面已经过时了,但是它支持Formtastic.

A couple of weeks ago someone made a fork to support Formtastic 2But then other additions were added to the master branch and were not commited to the fork. And now the fork is outdated with other things, but yet it support Formtastic.

如何使用git在我的计算机中本地合并它们?

How can I merge both of them locally in my computer using git?

推荐答案

这种最简单的方法是切换到本地Formtastic分支,然后运行git merge master合并主分支的更改(您可能必须在冲突之后处理冲突那个):

This simplest way is to switch to your local formtastic branch, then run git merge master to merge the master branch changes in (you may have to deal with conflicts after that):

git branch formtastic
git merge master

如果您希望历史记录更加井井有条,则可以改基础:

If you want your history to be a little more structured, you can rebase instead:

git branch formtastic
git rebase -i master

重新设置基准可以使您的历史记录更加整洁,因为它的工作方式是:将您在formastic中所做的任何更改都存储并缓存,然后合并到master中新的更改中,然后在顶部重播您的formastic更改.但是,这可能比简单地合并要花费更多的工作(并且您必须查找重新基准以了解其工作原理).

Rebasing will make your history cleaner because the way it works is it takes whatever changes you made in formtastic and caches them, then in merges in new changes from master, then it re-plays your formtastic changes on top. This may take a little more work than simply merging though (and you'll have to look up rebasing to understand how it works).

无论哪种方式,一旦所有内容都没有冲突,经过测试并在分支中提交了,则可以像下面这样将您的更改合并到master中:

Either way, once everything is conflict-free, tested, and committed in your branch, then you can go back and merge your changes into master like this:

git branch master
git merge formtastic

这篇关于如何在git中本地合并master和fork?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 05:14