Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Rails + Capistrano with Github and multiple branches

In my Rails app, I'm using Git, GitHub, and Capistrano. We have 2 servers (staging and production).

Up to now, I would make code changes on my local machine and push them to GitHub, then during deployment Capistrano would copy to either server from GitHub.

Now I have started using branches with Git. I created 2 branches locally on my machine, dev and prod. I'm the only developer at this point. I currently only have the branch master on GitHub.

Questions:

1) Should I create the dev and prod branches on the existing GitHub rpo or should I have a separate GitHub repo for staging and production?

2) If I do add branches, how would I tell Capistrano to use the dev branch for staging and the prod branch for production?

3) If using separate repos, how do I push a branch to the right one?

like image 533
Reddirt Avatar asked May 30 '26 08:05

Reddirt


1 Answers

I would not use separate branches for development and production. I would make an 'experimental' branch.

A branch is really designed to be a safe place where you can break off of your master (your working code), and try something experimental. So really master is your production branch, and development is any branch you make off of that. When you've made your changes on your other branch, commit them, and then use

git checkout master

git merge newbranch

to merge the newbranch in to your master.

like image 139
OneChillDude Avatar answered Jun 01 '26 22:06

OneChillDude



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!