Reputation: 9211
Say I have a Git repo folder where I do all my development. The master branch represents the production code and any development is merged in from different branches, as required. That's all fine. What if, now, I wanted to push the master branch somewhere within my local filesystem (e.g., a sibling folder), whenever I want to roll the master branch out to production?
Is this possible, with Git? For instance, say I have my project in ~/development/myProject-dev
, can I push just the master branch into ~/development/myProject
as a live mirror; that is, ~/development/myProject
is publicly accessible, whereas its -dev
brother has restricted access?
If this is fine, it seems like a good solution because ~/development/myProject
will also be a repo and can always be rolled back to a stable state, if say the changes made in development introduced a bug. Would you agree that this is a viable workflow? Are there better approaches (e.g., Git hooks, etc.)?
Upvotes: 4
Views: 1468
Reputation: 1260
You can push can do pulls and pushes locally with git. You can also clone only one branch into a new repository:
git clone ~/development/myProject-dev -b master ~/development/myProject
This command should clone only the master branch from your myProject-dev repo.
Upvotes: 2