You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Procedure to privately develop a feature branch of a public repository
Working with Public and Private Git Repositories
Sometimes you need to work with a public repository but want to develop a new feature privately. This guide shows how to create a branch from a public repo, push it to a private repo for development, and then move it back to the public repo when ready.
Step-by-Step Guide
1. Clone the Public Repository
git clone https://github.com/user/public-repo.git
cd public-repo
Procedure to move only specific commits to a branch while maintaining linear history.
Moving and Realigning Commits
Sometimes you need to transfer specific changes from a feature branch (e.g., dev) to a stable branch (e.g., main) without bringing over all subsequent development. This often involves:
Cherry-picking selected commits from dev onto main.
Rebasing dev to "fast-forward" its base to the newly updated main branch, making dev appear to branch from a later point.
This method results in a clean, linear history on main, making it easier to track specific feature integrations.
Important Note: This workflow rewrites the history of the dev branch. If dev is a shared branch that other team members are actively working on, performing a rebase will cause significant headaches and potential data loss for them. Only use this strategy on private or unshared branches.