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 fo
This tutorial gives a simple and straightforward answer :
forkedrepo
repositoryClone it locally:
git clone https://github.com/YOURUSERNAME/forkedrepo.git
Add the original github repository as remote of the new local repository:
git remote add upstream https://github.com/YOURUSERNAME/originalrepo.git
Pull down a copy of the original github repository to your new local repository:
git pull upstream master
Push the files from your new local repository to new github repository:
git push origin master
This won't be recognized by github as a fork of the original repository, off course, but this is as good as it gets.
Surprised no-one has referenced this guy's blog post yet.
Here's the relevant steps:
$ git clone git@github.com:YOURNAME/foo.git bar
$ cd bar
$ vim .git/config
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:YOURNAME/bar.git #replace foo with bar
$ git remote add upstream git@github.com:YOURNAME/foo.git
$ git push -u origin master
Instead of editing the config, I usually use a combination of git remote remove
and git remote add
.
You could also use git remote rename
followed by git remote add
if you wanted to keep the upstream origin around.
to make true GitHub fork of own repository you can use this steps:
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>
.
You're doing the right thing.
cd ~/Sites/
git clone ~/Dev/markupDNA/ project-N
cd project-N
git remote rename origin markupDNA
markupDNA
repo with custom nameSure you can clone from a clone. In git there is no concept of a main repo. People often designate a main repo, but that is by convention, not because of a technical reason.
So you can do everything exactly as you describe and even more.
For example it makes sense to keep a branch in your breakout sites with ideas for additions or modifications to your generic stuff. You can pull these up towards your generic repo and distribute again from there.