breaking into the unknown…

Leave a comment

git clone problem

Recently, I am asked to create a staging instance for our project, with exact same copy of environment as of production, so that code can be tested in exact environment before deploying on production. I was given ssh access to the new server space. When, I clone the repository on my local machine, it prompt me to enter my github username and password, and on authentication clone the repository.

But, when I tried to clone the repository, after login to the new server, I get into trouble, failing to clone it with every possible way I know.

=> Tried with https url
# git clone cportal
Cloning into cportal…
error: SSL certificate problem, verify that the CA cert is OK. Details:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed while accessing
fatal: HTTP request failed

=> Tried with simple http url
# git clone cportal
Cloning into cportal…
(gnome-ssh-askpass:5068): Gtk-WARNING **: cannot open display:

=> Tried with ssh url
# git clone cportal
Cloning into cportal…
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly.

O.K, so I understand the problem in first case, providing https in git url, means Git is expecting ssl certificate to be present on the machine trying to clone the repo. The new server do not have any ssl certificate so, it is failing. I have reported to client to purchase the certificate and add it to the new server.

In second case i,e with http , git try to secure the cloning by asking the repository username and password, but in my case the prompt to enter username and password is not appearing, so I ‘am struck up again.

I do not know the third problem i,e why with ssh url of the repository, it is saying Repository not found . Many a time I have cloned git repository with there ssh URL, but this time it is not working.

Searching a lot, finally, I got solution in this stackoverflow thread . It is long thread, with different people suggesting different things, but is worth reading.

Basically, in this case, my solution is to tell git to not verify the SSl certificate and do authentication with username password

1 : do not verfiy SSL certificate

NOTE : I have used it for temporary workaround. do not disable SSl verification, it will risk your repository. The correct solution is to add the SSl certificate on the machine

It can be done by running any of the below two commands :

export GIT_SSL_NO_VERIFY=false #export is linux command which can set any variable from the command line

git config –global http.sslVerify false

they will tell GIt to not verify SSL certificate while, cloning, pulling or pushing over https connection.
  2: enable the password prompt

The password prompt is having some value set, which is preventing it to appear. we need to remove that. jut opposite to export command which set a variable, unset will remove that variable. So below command should be used.




Leave a comment

steps to move from git to svn

I have been working with Git for long, but recently client asked to move the repository to SVN. I do not know, what benefits it will give over Git . Personally, I prefer working with git and find it better in managing my source code. A comparative analysis of commands used in both is available here . The one clear distinction between git and svn is that, in Git your code history is maintained both locally and remotely i,e say you are working on master branch locally, so when you do git diff it will compare changes from your local master branch rather than the remote master branch,  but with svn all history are maintained at some detached remote branch, and when you do diff , it compare the changes from that remote branch. Anyway, I follow the below steps.

STEP 1: Install svn in your system

$ sudo apt-get install svn

STEP 2: check that svn working properly

$ svn -h # It will list all the commands you can use with svn, You can use it whenever you want to know about a svn command

   blame (praise, annotate, ann)
   changelist (cl)
   checkout (co)
   commit (ci)
   copy (cp)

You can apply on any of these command to know more about them

$ svn ci -h # so it will tell about ci command
commit (ci): Send changes from your working copy to the repository.
Valid options:
  -q [–quiet]             : print nothing, or only summary information
  -N [–non-recursive]     : obsolete; try –depth=files or –depth=immediates
  -m [–message] ARG       : specify log message ARG
  -F [–file] ARG          : read log message from file ARG
  –force-log              : force validity of log message source

STEP 3: hosting ths SVN repository

This part is need to done by the client. There are a number of  service provider there like Assembla, Unfuddle , BeanStalk, CVSDude, ProjectLocker ,  etc. Go to any of them, create a account and get the url of the empty svn repository to which the developer will push there code . say you are provided  with below url by the client

STEP 4:  cloning the svn repository

$ cd Projects # I keep all my projects in this folder

$ svn checkout    arun-finance # so the code will copy to arun-finance folder, if not given name it will be copied with the repository name i,e my-finance

$ cd arun-finance # it contain only a .svn folder as no code is added to it yet

STEP  5:  Adding Files to SVN

I copied all the file from my local git repository except .git and .gitignore folder to this folder(now git is not needed)

$ svn status
?       db
?       Gemfile_back
?       spec
?       public
?       test
?       product.xml
?       app

The ? marks in svn means the file are untracked i,e not yet added to svn

$ svn add .
svn: warning: ‘.’ is already under version control # as the empty repository I cloned already have a .svn folder, so I added them as below

$ svn add script config lib Gemfile README.textile features public test product.xml app log Rakefile  Gemfile_back spec coverage vendor Gemfile.lock db

$ svn status
A       README.textile
A       public
A       public/favicon.ico
A       public/document_viewer
A       public/document_viewer/document_viewer.js
A       public/system


A       log/development.log
A       log/thin.log

So all files are now added to svn, but I have added lof file also, I do not want that so reverted as below

$ svn rm log –force # I have added log to svn, but not want it so reverted back

STEP 6 :  Pushing the code to the remote repository

$ svn ci -m”repository moved from git to svn”
Authentication realm: <; Subversion Repository
Password for ‘arun’: # give your system password
Authentication realm: <; Subversion Repository #
Username: arun123
Password for ‘arun123’: # the password with which you access the remote repository
Adding         Gemfile
Adding         Gemfile.lock
Adding         Gemfile_back


Transmitting file data ……………………………………………………………………………………………………………………..Committed revision 1.

So,  Your code is now available at the remote repository. You can see it your self by going to the repository url in the browser

$ svn up # this will update any change in the remote branch to your local branch
At revision  1.

STEP 7 : Deploying  remote svn repository to server

You can write deployment script for it, but for time being I did it manually. The logic is simple, You just need to login to your server and replace the source code taken from git earlier to the code pulled from the new svn repository.

$ ssh root@ # my server ssh path
root@’s password: year206
[root@cms05 ~]# cd ~/loan_projects

[root@cms05 loan_projects]# ls # showing the folder hosted with git


[root@cms05 loan_projects]# cp -R my_finance my_finance_git # backup the folder as my_finance_git, to revert back if anything goes wrong

[root@cms05 loan_projects]# rm -rf my_finance # You need to clone ths svn with the name of folder you are removing as your nginx or the other server is configured to read the source code from this folder, if name get changed you need to make change there also, to make it work again

[root@cms05 loan_projects]# svn checkout   my_finance

[root@cms05 loan_projects]# cd my_finance

[root@cms05 my_finance]# svn up # It will update the recent code from remote. run it evertime you want to deploy the recent code

[root@cms05 my_finance] #   move to the my_finance folder and run all the command you run earlier before restarting your server

[root@cms05 my_finance]# sudo /etc/init.d/nginx restart # restart the server

Now, Go to your site in browser, It is up as usual