1

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

A couple of weeks ago someone made a fork to support Formtastic 2 But 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.

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

Zequez
  • 3,399
  • 2
  • 31
  • 42

2 Answers2

1

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

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

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
Ben Lee
  • 52,489
  • 13
  • 125
  • 145
  • The problem is that is not a branch, it was forked: This is the original: https://github.com/gregbell/active_admin This is the fork: https://github.com/mak-it/active_admin/tree/formtastic – Zequez Oct 10 '11 at 19:44
  • @Zequez, see here for how to merge two different repos: http://stackoverflow.com/questions/1141338/can-i-merge-two-git-repositories-with-similar-content-but-not-sharing-any-ancest and http://stackoverflow.com/questions/244695/how-to-combine-two-branches-from-two-different-repositories-in-a-single-repositor – Ben Lee Oct 10 '11 at 19:49
  • Thanks! I didn't knew how to search ^^ – Zequez Oct 10 '11 at 20:15
0

You need to add a new remote reference to your upstream repo, the upstream repo being the original repo you have forked. See:

enter image description here

git remote add upstream https://github.com/gregbell/active_admin

Then you can fetch/pull from upstream and update your own local branch.
The various options are explained in "How do I clean up my Github fork so I can make clean pull requests?".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250