Luke
Luke

Reputation: 3541

clone from a git repo and commit to a new repository

I've created a skeleton theme for the Ghost blogging engine. And committed this to a github repo, I want to be able to clone this repo as a new theme.

$ cd ghost/content/themes
git clone https://github.com/StyxOfDynamite/styx_ghost_theme.git new_theme_name

$ ls -l
new_theme_name

this successfully creates a new theme, a copy of the base theme, however I want to change this and commit the new changes to a different repository not overwrite the changes to the base template....

How do I achieve this?

Upvotes: 8

Views: 5790

Answers (3)

Rerito
Rerito

Reputation: 6086

You have cloned your repository ... Now you should go under new_theme_name directory.

Here, if you type the command git remote, you should have origin displayed on your screen. Then, knowing your other repository url, you just have to type :

git remote set-url origin the_url_of_your_repo_here

Et voila ! This is much nicer than removing the whole .git directory. This way you will keep the history of the repository you had initially cloned.

If you use SSH to push (which is usually the case), don't forget to generate a pair of (public, private) key with ssh-keygen and to let the remote server know your public key.

Upvotes: 9

carols10cents
carols10cents

Reputation: 7014

Do you care if the history of the base theme is in the history of the new theme? If the presence of the history doesn't bother you, then you can to go to github.com and create a new repository with a different name (let's say new_theme_name).

Then, cd into your new_theme_name directory and change the URL that the origin remote is pointing to from the base theme's repo to the one you just created:

$ git remote set-url origin https://github.com/StyxOfDynamite/new_theme_name.git

Then when you commit changes and push, the changes will go to the new_theme_name repo instead.

Upvotes: 2

andrewvnice
andrewvnice

Reputation: 463

If I understand your question, then you've already cloned a base skeleton repo and you would like to use it for a new project and create a new repo from that.

You'll just need to delete the .git directory after you've cloned it, and then run git init to create a new repo with those files.

After running git init, just do git commit -a to commit all of the cloned files to source control.

You can also look into using git submodules which may be appropriate for what you need to do.

http://git-scm.com/book/en/Git-Tools-Submodules

Upvotes: 3

Related Questions