Poetry of Programming

Its about Ruby on Rails – Kiran Soumya

By

Installing RVM & Git through Proxy

RVM relies on GIT.

So set proxy for GIT first.

*  Set the http_proxy environment
*  Set a proxy command to bypass the connection:
gcc -o connect connect.c
mv connect ~/bin
echo “/home/kiran/bin/connect -H proxy.company.com:6030 $@” >> ~/bin/proxy
chmod +x ~/bin/proxy

echo “export GIT_PROXY_COMMAND=proxy” >> .bashrc

Now try git clone. If it doesnt work, try out the following the command.

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

This line below also works like a charm for GIT,

git config --global http.proxy proxy_addr:proxy_port

Once the GIT is configured, for RVM, you need to do one more change for curl,
Set the proxy inside your ~/.curlrc

proxy = proxy.company.com:proxy_port

and now you can install rvm with no issues.

For rvm install thru proxy:

rvm install X --proxy proxy.company.com:proxy_port

If two developers are under the same user-group, we can even clone/copy the .rvm folder within two users without explicit installations.

Some more references:
http://blog.iwkse.homeunix.org/index.php?/archives/9-Git-Basic-setup.html
http://beginrescueend.com/
http://zipizap.wordpress.com/2010/11/02/cloning-rvm-to-other-user-you-can-just-copy-the-rvm-directory/ [This worked for me as well]

By

Handling GIT Conflicts


I am attempting to push when I experience a conflict (ruby-1.9.2-p180)

cts_work/diaspora_cts git:(master)> git push origin master

To git@gitorious.org:diaspora_cts/diaspora_cts.git

 ! [rejected]        master -> master (non-fast-forward)

error: failed to push some refs to ‘git@gitorious.org:diaspora_cts/diaspora_cts.git’

To prevent you from losing history, non-fast-forward updates were rejected

Merge the remote changes (e.g. ‘git pull’) before pushing again.  See the

‘Note about fast-forwards’ section of ‘git push –help’ for details.

 

First, see if the conflict can be automatically resolved:

cts_work/diaspora_cts git:(master)> git pull

error: Your local changes to the following files would be overwritten by merge:

db/schema.rb

Please, commit your changes or stash them before you can merge.

Aborting

 

Git status shows that your state is conflicted:

cts_work/diaspora_cts git:(master)> git status

# On branch master

# Your branch and ‘origin/master’ have diverged,

# and have 2 and 1 different commit(s) each, respectively.

#

nothing to commit (working directory clean)

 

IMPORTANT – If you can resolve the conflict do so (normal procedure), this procedure presumes you wish to write the conflicting updates to a branch.

Reset your tree to just your unmerged updates:

cts_work/diaspora_cts git:(master)> git reset –hard HEAD

HEAD is now at 340a54e changes amde

 

Create a branch, use a name which suggests a conflict:

cts_work/diaspora_cts git:(master)> git branch conflict_stuff

cts_work/diaspora_cts git:(master)> git branch

  conflict_stuff

* master

 

Reset your tree to the prior revision:

cts_work/diaspora_cts git:(master)> git reset –hard HEAD

HEAD is now at 340a54e changes amde

 

Pull the other persons changes:(Do not do git pull but always git fetch + git merge)

cts_work/diaspora_cts git:(master)> git fetch

cts_work/diaspora_cts git:(master)> git merge origin/master

Merge made by recursive.

 app/controllers/sessions_controller.rb            |   21 ++++++—-

 app/models/profile.rb                             |    3 +-

 app/views/layouts/application.html.haml           |   14 +++—

 app/views/people/_profile_sidebar.html.haml       |   15 +++++–

 config/locales/diaspora/en.yml                    |    1 +

 db/migrate/20110226134747_add_columnto_profile.rb |    2 +

 db/schema.rb                                      |    5 ++-

 lib/tasks/profile_update.rake                     |   42 +++++++++++++++++++++

 public/javascripts/application.js                 |    2 +-

 9 files changed, 81 insertions(+), 24 deletions(-)

 create mode 100644 lib/tasks/profile_update.rake

 

Switch back to your branch:

cts_work/diaspora_cts git:(master)> git checkout conflict_stuff

Switched to branch ‘conflict_stuff’

cts_work/diaspora_cts git:(conflict_stuff)> git status

# On branch conflict_stuff

nothing to commit (working directory clean)

 

Push your conflict branch back to the repoistory:

cts_work/diaspora_cts git:(conflict_stuff)> git push origin master

Counting objects: 11, done.

Delta compression using up to 2 threads.

Compressing objects: 100% (8/8), done.

Writing objects: 100% (8/8), 861 bytes, done.

Total 8 (delta 5), reused 0 (delta 0)

=> Syncing Gitorious… [OK]

To git@gitorious.org:diaspora_cts/diaspora_cts.git

   d25e82a..c977122  master -> master