Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I fork my own GitHub repository?

So, total newbie to Git. Been reading through the guides and think I have the basics but am having difficulties accomplishing this one goal.

I have a repo created for my generic markup source code. Just stuff I reuse for every breakout. It's called markupDNA.git

I would like to have different directories in my mac sites dir ~/Sites/project-N. Where I build upon the generic stuff and do a breakout of a site. I would like these to be tied to my main git repo as forks, but you cannot fork your own repo?

I wish I could do something like this:

git clone <url> name git add . # make changes git commit -m 'whatever' git push 

But I don't want it to push to origin. I want it to push to a fork of the markupDNA repo whence it was cloned. But it seems like it just pushes my changes right up into the origin master. The idea is to keep the markupDNA clean and just have a lot of forks for my different projects, each of which will have their own cloned dir on my hard drive.

Any ideas?

like image 511
Fuego DeBassi Avatar asked Sep 22 '10 18:09

Fuego DeBassi


People also ask

How do you fork on GitHub?

Creating a fork on GitHub is as easy as clicking the “fork” button on the repository page. The fork will then appear in the list of your repositories on GitHub where you can clone it to your local machine and edit it. Once you are done editing, you push your commits back to the fork on GitHub.


2 Answers

You're doing the right thing.

cd ~/Sites/ git clone ~/Dev/markupDNA/ project-N cd project-N git remote rename origin markupDNA 
  • Nav to the folder where you store your projects
  • clone your base markupDNA repo with custom name
  • rename the remote so that if you want to an 'origin' later, you can
like image 129
kubi Avatar answered Oct 04 '22 11:10

kubi


It will probably be a lot easier to use branches, rather than using separate forks. You can still have separate checkouts for each branch; just clone your repo multiple times, and use git checkout in each one to switch it to the appropriate branch (or git checkout -b to create the branch and check it out all at once). Once you have created the branches, you can push them to GitHub using git push origin <branchname>.

like image 30
Brian Campbell Avatar answered Oct 04 '22 09:10

Brian Campbell