22 October 2012

Cloning a specific GIT branch from a repository


Step 1 : Clone the master branch
git clone <repo master>
Step 2 : Clone the specific GIT branch
git fetch origin +branchname:branchname
Step 3 : Switch to the branch
git checkout branchname
Step 4 : Check the file difference between the master and the branch 
git diff --name-status master..sibos

28 September 2012

Migrating code from SVN to GIT

Install git-svn on ubuntu or linux

Simple command to begin with
$ git-svn clone <svn repo link> --no-metadata -s my_project

You need to do a bit of post-import cleanup. For one thing, you should clean up the weird references that git svn set up. First you’ll move the tags so they’re actual tags rather than strange remote branches, and then you’ll move the rest of the branches so they’re local.

To move the tags to be proper Git tags, run

$ cp -Rf .git/refs/remotes/tags/* .git/refs/tags/
$ rm -Rf .git/refs/remotes/tags

This takes the references that were remote branches that started with tag/ and makes them real (lightweight) tags.

Next, move the rest of the references under refs/remotes to be local branches:

$ cp -Rf .git/refs/remotes/* .git/refs/heads/
$ rm -Rf .git/refs/remotes

Now all the old branches are real Git branches and all the old tags are real Git tags. The last thing to do is add your new Git server as a remote and push to it. Here is an example of adding your server as a remote:

$ git remote add origin git@my-git-server:myrepository.git

Because you want all your branches and tags to go up, you can now run this:

$ git push origin --all

11 August 2012

Fix Readline error Ubuntu

Fix readline error with Ruby

sudo apt-get install libreadline-dev

cd ~/.rvm/src/ruby-1.8.7-p249/ext/readline

ruby extconf.rb && make && make install


Thanks

10 August 2012

Capistrano + GIT : Too many arguments while deployment

Issue : shell command failed with return code 33024

It's a ruby + git clone + windows issue.

If I chain commands with && while calling system(cmd) from ruby, chaining "git clone" with other commands is not fine. Git clone perceives the chained commands as its own continuation, i.e. as a destination directory, unless I run it from the command line.
As I couldn't find any references or solutions to this problem on the internet, I put a hack to capistrano code, so "git clone" is executed separately. 

In <ruby directory>\lib\ruby\gems\1.8\gems\capistrano-2.5.18\lib\capistrano\recipes\deploy\strategy\base.rb after the line 53 (cmd = cmd.split...)
add the following lines:
if cmd =~ /\s\&\&\s/ && cmd =~ /^git\s+clone/
   cmd1, cmd = cmd.split(" && ", 2)
    super(cmd1)
end

it checks if it's a chained command and the first command is "git clone", and if such it executes it separately. It may not work for all possible cases.

Also you can try using ubuntu from your local.

 

09 August 2012

Installing RMagick with Imagemagic on Windows 7/Vista


2. Install Imagemagick
Use the 32 bit version, 64bit is not working.
http://www.imagemagick.org/download/binaries/ImageMagick-6.7.6-1-Q16-windows-dll.exe (2012-03-22)
Install dev headers (Check!)
Install into C:\opt\

3. Restart the console/cmd prompt/IDE/.. or just restart windows to make Imagemagick commands available

4. Install rmagick
gem install rmagick --platform=ruby -- --with-opt-lib=C:/opt/ImageMagick-6.7.6-Q16/lib --with-opt-include=c:/opt/ImageMagick-6.7.6-Q16/include

13 June 2012

Installing Ruby on Mac OS

STEP 1 Installing XCode


Please install XCode + Developer Tools from the App Center.
XCode is needed to install the Developer tools used in compilation of the Ruby packages for installation on the system.

STEP 2 Install RVM


Install RVM using the command
  • curl -L get.rvm.io | bash -s stable
This will install RVM on your system.
Please close and open the terminal again to load RVM.
To verify the RVM installation , open Terminal and type
  • rvm requirements
This will show a help doc.

Step 3 Installing required RVM packages before installing Ruby


Open Terminal and run the below mentioned commands one after the another
  • rvm pkg install zlib
  • rvm pkg install openssl
  • rvm pkg install iconv
  • rvm pkg install readline
  • rvm pkg install autoconf

Step 4 Installing Ruby


Open the Terminal and type the following command
  • rvm install 1.8.7 --with-gcc=clang
Here 1.8.7 reflects the Ruby version 1.8.7 and the latest patch, so to install any specific version or path you specify it by altering the above mentioned command eg.
  • rvm install 1.8.7-p334 --with-gcc=clang
  • rvm install 1.9.3 -C --with-gcc=clang

Step 5 Verify the installation


Open a new Terminal window and type
  • rvm list This will display the list of the different rubies installed on the system.
    To use a specific Ruby version use the following command
  • rvm use 1.8.7
  • rvm use 1.8.7-p334
  • rvm use 1.9.3 To make a Ruby version default for the system use the command
  • rvm alias create default 1.8.7
  • rvm alias create default 1.8.7-p334
  • rvm alias create default 1.9.3
This Ruby version will be the default version of Ruby on the system , to change to other versions of Ruby use the above mentioned commands.
To use default incase of switching use
  • rvm use default
To remove RVM from the system use the command
  • rvm implode

Installing Ruby on Ubuntu

Step 1 Verifying


Verify the system is update and then run a sudo apt-get update on the terminal.

Step 2 Installing RVM on Ubuntu


Open terminal and type
  • curl https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
This will install RVM on your system.
Please close and open the terminal again to load RVM.
To verify the RVM installation , open Terminal and type
  • rvm requirements
This will show a help doc.

Step 3 Installing required RVM packages before installing Ruby


Open Terminal and run the below mentioned commands one after the another
  • rvm pkg install zlib
  • rvm pkg install openssl
  • rvm pkg install iconv
  • rvm pkg install readline
  • rvm pkg install autoconf

Step 4 Installing Ruby


Open the Terminal and type the following command
  • rvm install 1.8.7 -C --with-openssl-dir=$rvm_path/usr --with-zlib-dir=$rvm_path/usr
Here 1.8.7 reflects the Ruby version 1.8.7 and the latest patch, so to install any specific version or path you specify it by altering the above mentioned command eg.
  • rvm install 1.8.7-p334 -C --with-openssl-dir=$rvm_path/usr --with-zlib-dir=$rvm_path/usr
  • rvm install 1.9.3 -C --with-openssl-dir=$rvm_path/usr --with-zlib-dir=$rvm_path/usr

Step 5 Verify the installation


Open a new Terminal window and type
  • rvm list This will display the list of the different rubies installed on the system.
    To use a specific Ruby version use the following command
  • rvm use 1.8.7
  • rvm use 1.8.7-p334
  • rvm use 1.9.3 To make a Ruby version default for the system use the command
  • rvm alias create default 1.8.7
  • rvm alias create default 1.8.7-p334
  • rvm alias create default 1.9.3
This Ruby version will be the default version of Ruby on the system , to change to other versions of Ruby use the above mentioned commands.
To use default incase of switching use
  • rvm use default
To remove RVM from the system use the command
  • rvm implode