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

 

Advertisements

CFWheels and Git: Ignoring unpacked plugin directories

Posted in CFWheels, Git by rip747 on November 2, 2009

Just a quick little git and Wheels tip. Most of the time, you might only want to track your plugins .zip file in your repo and ignore the plugin’s unpacked directory since it’s pretty much redundant to track both. In order to do this, create a .gitignore file where your .git directory lives. In it add the following:

plugins/**/*

What that does is essentially tells git to ignore any subdirectories off the main plugin directory.

Websites and SCMs branches, there has to be a better way.

Posted in Apache, Git, IIS, Linux, SCM, SVN, Windows by rip747 on September 24, 2009

Has this ever happened to you? You’re programming a website and within your source control manager (SCM) you have several branches. One branch could be the current version of the website (trunk or master depending on your SCM) and other branches could contain some new features or bugs fixes that you’re working on.

Now you want to test out or show the new features or bugfixes to your team or employer that are contained within these other branches and this is where the problem lies, how do you deploy these branches? Well its pretty easy right? You setup and configure an entirely new website to have the people hit that branch. So if your current version is residing on http://www.example.com, you might setup and configure a new website at www1.example.com for the branch you want people to have a look at.

To me this is a HUGE waste of time. For every branch you need to demo or test, you need to create a new website. Wouldn’t it be great if there was something out there that could allow the webserver to talk to your SCM directly and pull back the branch that you want simply be addressing it in the url?

For instance. Let’s say in my SCM I have a master branch containing the current version of the website and a branch called bug27 that contains some fixes for a bug I’m working on. Now if I wanted people to access both of these branches from the internet, I would have to configure two websites on my webserver. http://www.example.com would point to a directory containing the master branch files and bug27.example.com would point a different directory containing the bug27 branch files.

Imagine if all I had to do was to configure one website with two host headers, one for master at http://www.example.com and one for bug27 at bug27.example.com. Then just point the website to my SCM repo. Now depending on which host the people come to the website with, the webserver would be smart enough to pull back that branch from my SCM. This totally eliminates the need to configure a new website for every branch that you have.

That said, is there anything out there like this for Apache or IIS?

Export files from a revision or range of revisions with Git

Posted in Git by rip747 on July 29, 2009

If there is one thing I miss about using TortoiseSVN was the convinence of exporting a group of files from a revision or range of revisions. Currently I know of no way of doing this in Git, so I decided to roll my own Git alias to accomplish this.

The alias below takes two arguments:

  1. the revision or range of revision you want to export files from
  2. the directory you want to place them in

So if you want to export all the changed files from HEAD to HEAD~2 and put them in the /cygdrive/c/temp directory, you would do:

$ git exportfiles HEAD..HEAD~2 '/cygdrive/c/temp'

The code is below:

exportfiles = !sh -c 'git diff $0 --name-only | "while read files; do mkdir -p \"$1/$(dirname $files)\"; cp -vf $files $1/$(dirname $files); done"'

Just cut and paste it into the [alias] portion of you .git/config file and you’re ready to go.

As always, if you have a better solution, please leave it in the comments below.

Reviving a git-svn clone

Posted in Git by rip747 on June 17, 2009

Compiled by following: http://osdir.com/ml/git/2009-04/msg01781.html

Thank you Martin Krafft @ http://madduck.net/, you saved my ass and I don’t even know you 🙂

Here’s the problem. I’m mirroring the CFWheels SVN repo (please migrate to github) using git and github. Last week my cygwin installation took a dive and in the midst of trying to fix it, I screwed up my local git repo used to do this mirror (completely my fault and not git’s or cygwin’s. Yes, I’m an idiot).

Anywho, I finally got everything up and running with cygwin, but now came the problem of getting the mirror working again. In the past to accomplish this, I actually did a forced push to the master branch on the mirror. It was OK since noone at the time had forked the mirror so it didn’t hurt anything. But now we have some people who have forked the mirror, so this isn’t an option for me any more. I actually had to figure out how to fix this.

After A LOT of searching and reading here is how I revived my git mirror of the CFWheels SVN repo. It turned out to be 4 simple command in git:

$ mkdir cfwheels
$ cd cfwheels
$ git clone git@github.com:rip747/cfwheels.git
$ git svn init https://cfwheels.googlecode.com/svn/trunk
$ git update-ref refs/remotes/git-svn refs/remotes/origin/master
$ git svn rebase

Now to explain each line (so I don’t forget):

$ mkdir cfwheels
$ cd cfwheels

Obviously I’m making a directory on my machine called cfwheels and switching to it (basic stuff)

$ git clone git@github.com:rip747/cfwheels.git

Here I’m cloning the svn mirror repo from github.

$ git svn init https://cfwheels.googlecode.com/svn/trunk

Here I’m creating a reference to the cfwheels repo on googlecode in my local git repo

$ git update-ref refs/remotes/git-svn refs/remotes/origin/master

This is the secret sauce! What I’m doing here is updating the HEAD of the git-svn remote (refs/remotes/git-svn, this is created for you by doing the “git svn init”) to match the HEAD I grabbed from github (refs/remotes/origin/master, again this is created for you by doing the “git clone”).

$ git svn rebase

Now that the two heads match, I’m able to pull the revision information from googlecode. What you’ll see at this point is a mess of lines run on the screen which corresponds to each commit in the svn repo. At the end you should get the following message:

Done rebuilding .git/svn/git-svn/.rev_map.d8ff095c-9719-0410-9cd3-1dd5d13d90f5
Current branch master is up to date.

Hopefully this helps you out. If I missed anything or you have an updated way to do this, please comment below.

Git-Svn: Will it ever work again?

Posted in Git by rip747 on June 11, 2009

UPDATE: I have created a custom cygwin repository that you can run setup against to get the last working version (1.5.6-1). You can download it from the box.net widget to the right or by clicking here.

Well it seems that I’ve completed hosed myself good. At work I updated my cygwin install and it installed the latest git and subversion packages. Long story short, this completely broke git-svn to the point where I can’t use it. What sucks is that I use git-svn to contribute to CFWheels which I’m using right now to rewrite some websites. It’s nice to be able to find a bug and fix it then and there and not have to wait until I get home.

Luckily I raced home tonight and saw that my cygwin installation on my home computer wasn’t upgraded, so that means I’m still able to contribute.

What really pissed me off is that this has been broken since version 1.5.6-1 and for over 4 months and hasn’t been fixed yet. I tried to install msysgit at work to see if that would work for me, but it’s a no go since their subversion packages are at 1.4 and GoogleCode is on 1.5.

Even sadder is that msysgit doesn’t seem to want to upgrade their subversion packages anytime soon as the maintainer himself told me here.

With the on going cygwin and msysgit problems, will git-svn ever get fixed?

Git: push rejected non-fast forward

Posted in Git, TechSupport by rip747 on April 20, 2009

When trying to do a push to a repo, you might encounter the following error:

$ git push github master
To git@gitproxy:rip747/cfwheels.git
! [rejected]        master -> master (non-fast forward)
error: failed to push some refs to ‘git@gitproxy:rip747/cfwheels.git’

Don’t panic, this is extremely easy to fix. All you have to do is issue a pull and your branch will be fast-forward:

$ git pull github master
From git@gitproxy:rip747/cfwheels
* branch            master     -> FETCH_HEAD
Already uptodate!
Merge made by recursive.

Then retry your push and everything should be fine:

$ git push github master
Counting objects: 44, done.
Compressing objects: 100% (32/32), done.
Writing objects: 100% (32/32), 6.30 KiB, done.
Total 32 (delta 23), reused 0 (delta 0)
To git@gitproxy:rip747/cfwheels.git
1717535..1406e8c  master -> master

UPDATE: I ran into another instance of this that the solution above didn’t solve and have provided a solution below.

Another situation where you might run into this, is if you’re tracking a branch that is not the same name as the remote. For instance, say you have a remote branch called otherrepo/master and you already have a local master branch, so you checkout the otherrepo/master branch as othermaster locally. Now even though you do a pull, when you go to push, you will get the rejected error.

To get around this, you will have to specify the local branch in the push command using a colon (:) like so:

git push otherrepo othermaster:master

CF8.XML now on github

Posted in CFEclipse, ColdFusion, Git, Opensource by rip747 on January 30, 2009

So in my attempt to learn git better and get more people contributing and wanting to contribute to my projects, I’ve started moving everything over to github. My first move is of course the CF8 syntax library for CFEclipse. Because of this, I’m going to remove it from the box.net widget and place it in a new github section of the links to the right.

GIT clone over HTTP: who knew?

Posted in Git, TechSupport by rip747 on September 12, 2008

Quick note for others and so I don’t forget.

If you’re behind a proxy (like I am) and try to do a git-clone using the git:// protocol, surely it will fail if you’re firewall is restrictive. The beautiful thing is, you can use http:// protocol instead to get around this restriction.

So for instance, let’s say we want to clone a copy of yubnub from github. In the cygwin command line, you would normally do:

git clone git://github.com/jcnetdev/yubnub.git

However that will fail. Instead do:

git clone http://github.com/jcnetdev/yubnub.git

The only other gotcha is that you might need to setup your proxy in your environment. To do this, simply do:

export http_proxy=http://<username>:<password>@<proxy_ip>:<proxy_port>

where:

username = your network username (someuser)
password = your network password (somepassword)
proxy_ip = the ip address of your proxy server (192.168.1.1)
proxy_port = the port number for the proxy (80)

the full string would look like this:

export http_proxy=http://someuser:somepassword@192.168.1.1:80

Tagged with:

Getting Git-SVN to work under Cygwin

Posted in Cygwin, Git, TechSupport by rip747 on September 4, 2008

This has taken me DAYS to get working and finally i got it. Here are the steps:

Download the Cgywin setup.exe from the Cygwin site.

Next is to READ AND FOLLOW the instructions for setting up Git during the install. The instruction are at the bottom of the page entitled “Install Cygwin”.

After the installation you will need to run “ash rebaseall” from the cygwin\bin directory in a command line in order to update Git-SVN. So open a command prompt (START -> RUN -> CMD) and type in cd\cygwin\bin (or whatever your cygwin installation folder is) and run “ash rebaseall”.

Hopefully this help someone out there

Tagged with: