Rip's Domain

My CFWheels git workflow

Posted in CFWheels, Git by rip747 on January 29, 2011

the other day i was asked whether we should clone the official repo or fork it to our own repo for doing development. i suggested that we use a fork for development and not the official repo.

the big reason i say this is so that you have your own repo to experiment with and commit to. this becomes instrumental when working on new features or fixing bugs as you can do them in separate branches
and then only commit back to the official repo when they are completed and tested.

the issue though comes when you want to commit your changes to the official repo and getting setup in order to do so. this is a quick write up on how i’m doing it currently, feedback is welcomed. i’ll go from start to finish in this walk through. from forking and setting up a local repo to work off of, to finally pushing your changes to both your forked repo and the official repo.

again, comments and suggestions are more then welcomed.

======================================================

first login to your github account
go to the official repo at cfwheels/cfwheels
click the “fork” button at the top to create your fork

======================================================

now we need to clone our fork to our local machine. i’m on windows but it’s the same on the mac through the command line. we’ll be cloning the repo into a “cfwheels” directory.

// clone your fork. substitute “rip747” for your username
git clone git@github.com:rip747/cfwheels.git cfwheels

// change directory into the newly created one
cd cfwheels

// list all the branches to make sure everything went cool
// you should see master, 1.0, 1.1, HEAD (this is at the time of this writing)
// the current checked out branch will be master
git branch -a

* master
origin/1.0
origin/1.1
origin/HEAD
origin/master

// now link the official repo as another remote
git remote add wheels git@github.com:cfwheels/cfwheels.git

// fetch the list of branches from the newly created wheels remote
git fetch wheels

From git@github.com:cfwheels/cfwheels
* [new branch]      1.0        -> wheels/1.0
* [new branch]      1.1        -> wheels/1.1
* [new branch]      master     -> wheels/master

// listing all the branches again you will see your fork branches and the wheels one
git branch -a

* master
origin/1.0
origin/1.1
origin/HEAD
origin/master
wheels/1.0
wheels/1.1
wheels/master

==============================================

so at this point you’ve got your repo to work off of and a connection to the official wheels repo to push your finished changes to. so let’s go through an example of creating a new branch to work off of, making changes, merging those changes and finally push them up to both our fork and the official wheels repo

// let’s start by making sure we checkout the master branch
git checkout master

// let’s create a new branch from master to work off of
git checkout -b my_new_feature

// let’s just touch a new file and commit it
touch README

// add the new file
git add README

// commit the new file
git commit -m “adding README”

// now we’ll checkout master and merge out changes
git checkout master

// merge our changes in
git merge my_new_feature

// now we can push our changes to OUR fork
git push origin master

===========================================

at this point our changes have been pushed to our fork. now let’s merge our changes into the official repo

// checkout the corresponding branch (in this case master) from our wheels remote
// i have a habit of naming them <remote>-<branch>
git checkout –track -b wheels-master wheels/master

// merge the changes we made in our master branch
git merge master

// push the change to the official repo
git push wheels wheels-master

// switch back to out master branch
git checkout master

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: