Sunday, July 10, 2011

Git - How to push to multiple remotes

A neat way to push to multiple remotes. This would allow you to push to 'all' remotes

git push all HEAD:<branch>

 
This is especially useful when you use dropbox as an additional remote. Edit the .git/config in the local repo and add the following
[remote "all"]
    url = <git-url-1>
    url = <git-url-2>
    url = <git-url-3>

Saturday, June 11, 2011

Using dropbox as a git repo

I find using dropbox as a convenient way to access you code anywhere I want. The first step is to create a git repo in your dropbox directory:

mkdir myproject.git
cd myproject.git
git init --bare


For a new project, you can clone the git repo in dropbox

cd <where/you/want/your/project>
git clone <path/to/dropbox/..../myproject.git>
cd myproject
[hack.. hack.. hack]
git add <what you want to commit>
git commit [...]
git push


git push will push your changes to remote (the repo in dropbox). Now to continue your work elsewhere, you just have to let the dropbox do it sync and repeat steps above and push. This method can work even for an existing git project. You can create a bare git repo in dropbox, add the repo-in-dropbox as a new remote and push.

cd <where/you/your/project/is>
git remote add dropbox <path/to/dropbox/..../myproject.git>
git fetch dropbox
[hack.. hack.. hack]
git add <what you want to commit>
git commit [...]
git push dropbox HEAD:master


Substituting dropbox with an usb-stick will also work :-)

Tuesday, June 7, 2011

Let me know when it is done

A convenient way to get notified when waiting for a long process to end is to use the alert command/alias. On ubuntu, while copying a large file or compiling a program which takes a long time; I would switch to read emails or facebook and lose focus of my current task. Alert notifies you once the process is over and helps me get back on track. 

How do you use alert?


a-long-process; alert 


incase you are missing the alert alias, just add this to your .bashrc or .profile

alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

Monday, May 2, 2011

Impatient perl: an accelerated introduction to perl

Was never a big fan of Perl but that has stated to change after I found this nice little introduction to perl. Thanks to Greg London for writing this book for the impatient.