Sharing Commits Between Repos
If you ever want to make some sort of template available to the public but want to keep your own implementation in a private repository, such as a website theme or a job application template, this may be the sort of git flow you need.
The following method is super simple, really. It’s just a matter of adding new remotes to both repositories and cherry picking individual commits. Doing it this way avoids adding your personal details to a template or vice versa. Obviously, the key to this is strictly separating all commits into personal and public changes.
Add repositories as remotes
Add the public to the private and the private to the public so cherry picking can be done both ways.
From the private repo:
git remote add template git@github.com:username/my-awesome-template
From the public repo:
git remote add personal git@github.com:username/my-awesome-implementation
Cherry pick feature commit(s)
Example: Assume that a feature was added to the personal implementation in a branch called awesome-feature that needs to be introduced to the public repo.
From the public repo:
git fetch personal
git log personal/awesome-feature -n 5
git cherry-pick ${commit-hash}
And if there’s no need to bother with manually resolving conflicts, you can choose to accept all incoming changes:
git cherry-pick -X theirs ${commit-hash} - Clint Jordan