Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clone from a git repo and commit to a new repository

Tags:

git

github

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?

like image 550
Luke Avatar asked Oct 27 '13 21:10

Luke


People also ask

How do I clone a git repository to another repository?

Navigate to the repository you just cloned. Pull in the repository's Git Large File Storage objects. Mirror-push to the new repository. Push the repository's Git Large File Storage objects to your mirror.


3 Answers

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.

like image 162
Rerito Avatar answered Oct 05 '22 07:10

Rerito


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

like image 41
andrewvnice Avatar answered Oct 05 '22 07:10

andrewvnice


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.

like image 23
carols10cents Avatar answered Oct 05 '22 09:10

carols10cents