1

I created a Project (https://github.com/twaldecker/vim-cheat-sheet) and now I realized that I like the style of the cheatsheet and want to create a template out of it.

What I did is:

git clone cheatsheet-vim cheatsheet-template
cd cheatsheet-template
# remove vim specific content, some additions
cd ../cheatsheet-vim #go back to vim project
git checkout -b testbranch #create a new branch
git remote add template ../cheatsheet-template
git fetch template
git merge template/master #now I got the template project as branch in the base project

The question now is how to let the vim-cheatsheet project base on the template created out of the project itself.

What I want to have:

  • have the template project which I can change
  • have the cheatsheet-vim project where I can pull the canges from the template
Thomas
  • 2,127
  • 1
  • 32
  • 45
  • I know the source is not very large and it would be easy to just recreate the vim-cheatsheet and copy the relevant sources back but I would like to learn the real git way. – Thomas Dec 13 '12 at 14:06

1 Answers1

1

In your case, since you have two branches without a common ancestor, you can try and rebase --onto your current master on top of template/master (with 'template' being the name of your remote referring the template repo).

That is one of the solutions presented in "How to merge two branches without a common ancestor?".

That way, the two branches will have a common history, and you will be able to do so git pull --rebase when your template changes (to rebase again your current work on top of the modified fetched template)


The OP Thomas tool another approach and commented:

I ended up creating a new Project and copy the source.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks for your answer, but I think it doesn't answer my question. The template is based of the vim-cheatsheet and then removed the content. Now I want the vim-cheatsheet base on the template. – Thomas Dec 13 '12 at 14:50
  • 1
    @Thomas "I want the vim-cheatsheet base on the template": that is what the `rebase --onto` would do: reapply what you have done in vim-cheatsheet on top of (ie "based on") the template. – VonC Dec 13 '12 at 15:08
  • I ended up creating a new Project and copy the source. – Thomas Dec 21 '12 at 16:41
  • @Thomas ok, I have included your conclusion in the answer for more visibility. – VonC Dec 21 '12 at 22:16