I have this small project for my brother that I need to create backend functions for his website. But I haven't been able to work on it as much (or fast) as I'd like to since I'm always doing things away from my computer. I could bring around my notebook with me but it's not that convenient. Then I thought it would be nice if I could use my old-yet-still-functioning-good cellphone, thunderbolt, for coding and could share it with my other computers since I carry it with me all the time.
Bang! Why not! Then I started searching apps for editors, web servers, and version control, etc... Editor and web server were relatively easy to find. I decided to use Vim Touch for editor and AndroPHP for web server. A problem was with a version control app. I've used git for other projects so I wanted to use it for this but I couldn't find a suitable app. When I was almost giving up this whole idea, I realized that I had Terminal IDE and gave a try to see if it had git installed. Voilà! It had git installed.
The information below is the result of my researches in the Internet and of my experiences. It is solely used for my purpose and may not be suitable for others.
Getting its environment for git and remote origin:
The version of git on my cellphone is 1.7.8:
$ git --version
git version 188.8.131.52.g9859a.dirty
I have a remote repository at bitbucket.org and tied to clone it to my cellphone:
$ git clone https://[username]@bitbucket.org/[username]/[reponame].git
Cloning into '[reponame]'...
fatal: cannot exec 'git-remote-https': Permission denied
Oops... it's not working. After googling, I found that Terminal IDE doesn't support HTTPS for authentication. That leaves me with SSH authentication.
Generating SSH Keys:
Terminal IDE comes with the command dropbearkey which is a relatively small SSH server and client that's capable of running on a variety of POSIX-based platforms. It's easy to create a new key:
$ mkdir ~/.ssh
$ dropbearkey -t rsa -f ~/.ssh/id_rsa
This will create a passphrase-less pair of public/private keys. If the public key needs to be viewed later time, this command does the job:
$ dropbearkey -y -f ~/.ssh/id_rsa
SSH now needs to be mapped to a new key:
$ vim ~/.bashrc
alias ssh='ssh -i ~/.ssh/id_rsa'
But git uses a bit different way to handle this:
$ vim /data/data/com.spartacusrex.spartacuside/files/bin/ssh_git
exec ssh -i ~/.ssh/id_rsa "$@"
Then make it executable:
$ chmod 755 /data/data/com.spartacusrex.spartacuside/files/bin/ssh_git
And set an environment variable:
$ vim ~/.bashrc
[Edit: I forgot to mention about registering the public key to Bitbucket]
Note: If you get No auth methods could be used error, most likely ssh is not loading your key or you forget to register the public key to your server (in my case bitbucket.org)
$ ssh -T firstname.lastname@example.org
ssh: connection to email@example.com:22 No auth methods could be used.
Before connecting to bitbucket.org, the public key must be registered to my account at bitbucket. To do so, convert the key to OpenSSH format:
$ dropbearkey -y -f ~/.ssh/id_rsa | grep "^ssh-rsa" > ssh_key
Then, log into bitbucket.org. Go to Avatar → Manage account → SSH Keys → Add Key. Then copy the content of ssh_key file generated above. Once this is done, the connection should be successfully made.
Now restart Terminal IDE and try to connect to bitbucket.org:
$ ssh -T firstname.lastname@example.org logged in as [username]. You can use git or hg to connect to Bitbucket. Shell access is disabled.
Good. That means it's successfully connected to the server.
Cloning my repository:
First create a directory where I can clone my repository into:
$ ln -s /mnt/sdcard/www www && cd www
Then clone it from my account at bitbucket.org:
$ git clone email@example.com:[username]/[repository_name].git
Setting up the environment for git:
Let's configure git:
$ git config user.name "[username]"
$ git config user.email "[username]@[server]"
Git is a very versatile tool and it has some very versatile ways to be configured:
$ vim ~/.bashrc
With all of this, my old-but-trusting thunderbolt becomes my primary coding device!