-1

I have one repository in Github this repository has 2 branches (main branch) and (specific features branch), what I need to achieve when I write my code I know this code is a core feature that I need to exist into both (main and specific features) branches this can be done easily when I do merge from (specific features) branch to (main) branch.

My question: - if I did 3 commits to (specific features) branch I need the first commit to be merged to the (main) branch but I don't want the second and third commit to being merged to (main) branch applies that the other developer pulls to his machine the 3 commits. can some one help please, this is useful to write a code one time for 2 projects, is there any way to achieve that by using git or svn. is there a special setup in Github that will allow me to do it?

  • 2
    Why do you mention svn? – evolutionxbox Aug 17 '21 at 23:07
  • thanks for the answer but what I'm looking for is more interface interactive in GitHub when you select to create a pull request and there you will do merge between (specific features) branch and (main) branch the list of all commits will appear but I want to exclude some of them I don't all of them to be merged to the (main) branch – odai jawasreh Aug 17 '21 at 23:24

1 Answers1

0

Yeah! You can create an orphan branch:

git checkout --orphan {name}

This will create a new branch, independent to your current branch. Whole project must have its own orphan branch

Cleanup the project after an orphan created checkout:

rm .git/index

rm -r *

Now, you can create two independent repositories, and push the commits

Example:

git push origin main:main-1

git push origin main:main-2

Git docs reference

ianbandrade
  • 46
  • 1
  • 4