Question

I have master branch https://github.com/Fivell/PHP_PROJECT/ and recently created new branch for php 5.3 https://github.com/Fivell/PHP_PROJECT/tree/php5.3

But I think It will be better to create fork instead of branch in this case. Can anybody help with it ? How can I create fork of my own project , than merge it with fork php5.3 and than delete branch ?

Was it helpful?

Solution

You cannot fork your own project on GitHub.

One solution would to create another account, and fork from there.

The other is a "manual fork", ie a local clone of your GitHub repo "uploaded" (git push) to a new empty gitHub repo (but there won't be any "pull request" link possible between the two repo)

See this gist:

Let’s assume we have an existing project called ‘foo’ and we want to create a fork called ‘bar’.

First, create a new project on GitHub called ‘bar’.

Next, clone foo using the name ‘bar’:

$ git clone git@github.com:YOURNAME/foo.git bar
$ cd bar

Next, edit your Git config file and replace the origin URL with your new URL:

$ vim .git/config

Add your original repo as an upstream source:

$ git remote add upstream git@github.com:YOURNAME/foo.git

Finally, push your new repository up to GitHub:

$ git push -u origin master

Now you can push/pull from your new repo (bar) as expected.
You should also be able to merge upstream changes using the following command:

$ git fetch upstream
$ git merge upstream/master

The OP adds:

what about opportunity to create pull requests from new fork to current master ? Any edit ?

I replied in the comments:

There won't be any pull request, only fetch from your "manually forked" repo directly to your local clone of your main GitHub repo.
Ie: you would add a second remote to your local repo, pointing to your "manual fork" on GitHub

So if you publish any modification on your second repo on GitHub (the "manual fork"), you can fetch them directly in the local clone of your original GitHub repo, merge them, test them, and finally push them back to said original repo.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top