4

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.)?

1

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Are there any advantages of clone over push (or vice versa) in this instance?
I believe that a 'clone' is very similar to a 'init' followed by a 'pull' (plus adding a remote called "origin"). After you have done either of these you will need to keep it up to date with the origin by doing 'git pull origin master'
Ah, I see: So you control the mirroring from the mirror, so to speak, rather than pushing from myProject-dev whenever necessary?
Exactly, you push from the original and pull from the other

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.