LogicalDoc Install Instructions

I been faced with a simple task to install LogicalDoc on a Centos Machine which is actually  a XenServer Virtual Machine. The LogicalDoc install instruction are how helpful i leave the users of the blog to decide. The simple job became a roller coaster ride and i was not able to find answer to some of the questions.

Lets get started on How we install LogicalDoc on a XenServer VM. First step offcourse is to install the XenServer. We are using XenServer 6.1 on a Dell R720 Machine with Two Quad Core CPU and 64 Gb Rams. Yes it is very mean machine.

Any way, the LogicalDoc is to be installed on CentOS with 2 Cores out of 24 Cores available in XenServer with 8 Gb of Ram. Installing a CentOS on a VM is again out of scope of this post. There are a number of examples on how to install a CentOS on XenServer VM. We are using CentOS 6.3.

If you land on this page http://dist.logicaldoc.com/dist/logicaldoc/ and read about dependencies i.e. Java SDK 6+ aka jdk6u then you are for a surprise as you find one of the important thing is missing in the instructions in this page http://dist.logicaldoc.com/dist/logicaldoc/howto/cross-platform.html

Off course, you need to install the jdk6u+ but once you try to fire that from the command line you will not be able to do that.

Reason is this page is not complete instructions. Here is the complete instruction for Linux install from this page http://help.logicaldoc.com/en/installation/install-on-linux.html

Install on Linux

On Linux the MySQL automatic installation is not provided as for Windows. So make sure to have a MySQL 5.0(or later) up and running in your system.
On Linux we suggest to install and execute LogicalDOC as root user, to make sure to log-in as root before continuing, since this guide assumes you perform all thing as root.

Also since the LogicalDOC installer is a graphical application, you need to launch it from KDE or GNOME.

It would have been nice if the same are mentioned in the same page of link is given. Any way, first Road Block was solved using VNC for XenServer. Follow this post to set that up


Once you are done the other important thing is you need to install this as root user. Do not attempt as any other user you might encounter this error.

GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details –  1: Failed to get connection to session: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.)

GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details –  1: Failed to get connection to session: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.)

GConf Error: Failed to contact configuration server; some possible causes are that you need to enable TCP/IP networking for ORBit, or you have stale NFS locks due to a system crash. See http://projects.gnome.org/gconf/ for information. (Details –  1: Failed to get connection to session: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.)

And the LogicalDoc Enterprise support team will not be able to help you citing liability issues which I fail to understand what it is.

Any way once this is out of the way, It is pretty much straight install. It is recommended that you make mysql db and user account to manage that db in advance as the same will be required during install.

Other thing you can change is the tomcat port which defaults to 8080, 8443. Since we are running a VM i changed it to 80 and 443.

Once done then you need to start the tomcat using the start.sh script located in tomcat/bin folder. I m still to find a way to put in init.d to respawn on failure


VNC Server on Xen Server Centos VM

VNC is a protocol that is used to share the desktop with other users/computers over the network/Internet.In order to share a desktop, VNC server must be install and configure on the computer and VNC client must be run on the computer that will access the shared desktop.

When we install the minimal copy of CentOS Server, it only gives us the “Command Line” interface.

But some people prefer GUI instead and for this they install Full version of Gnome on CentOS. Actually there is a better way and that is to install VNC. VNC provides a lightweight virtual desktop than full blown version of Gnome.

To run the VNC Server on CentOS, we have to install these required packages:

sudo yum groupinstall Desktop
sudo yum install tigervnc-server
sudo yum install xorg-x11-fonts-Type1

This is optional:

sudo yum install vnc

To start VNC Server on boot

sudo chkconfig vncserver on

To setup users’ VNC password:


Edit the /etc/sysconfig/vncservers file:

sudo nano /etc/sysconfig/vncservers

Add the following to the end of the file:

VNCSERVERARGS[1]="-geometry 1024x600"

The iptables rules need to be amended to open the VNC ports:

sudo iptables -I INPUT 5 -m state --state NEW -m tcp -p tcp -m multiport --dports 5901:5903,6001:6003 -j ACCEPT
sudo service iptables save
sudo service iptables restart

Start the VNC Server as the user whom you want to connect. This will create the xstartup file in ~/.vnc folder


Now kill the VNC Server:

vncserver -kill :1

Edit the xstartup file in .vnc directory:

nano .vnc/xstartup

Comment the last line and run the Gnome:

#twm & 
exec gnome-session &

Restart the service:

sudo service vncserver restart

Now, download VNCViewer onto our desktop computer from which we want to access the shared desktop. Connect using ServerIP/Name:1 (:1 is for the VNC server window), In my case it is centos:1.

Enter the password that we created using the vncpasswd command:

We now have GUI access to our server.

Ability to connect for multiple users:

Create a local user, using the following command:

sudo adduser test


Create a password for newly created user:

sudo passwd test

Switch to the newly created user and run vncpasswd command for it:

su test

Edit the /etc/sysconfig/vncservers file:

sudo nano /etc/sysconfig/vncservers

Add these lines for new user:

VNCSERVERS="1:arbab 2:test"
VNCSERVERARGS[1]="-geometry 1024x600"
VNCSERVERARGS[2]="-geometry 1024x600"

Restart the VNC service:

sudo service vncserver restart

Kill the vncserver session for new user and edit the xstartup file:

su test
vncserver -kill :2
cd ~
nano .vnc/xstartup

Modify the file so it looks like this:

#twm & 
exec gnome-session &

Restart the VNC service:

sudo service vncserver restart

Connect with newly created user using centos:2, Where centos is my server name:

Enter the password that we created using the vncpasswd command:

We now have GUI access to our server for newly created user.

Setup Etherpad Lite

Etherpad Lite is a lightweight version of (probably) the most popular web-based collaborative real-time editor – Etherpad. This great peace of software allows multiple users to edit the same document in real-time. To make collaboration easier, users have built-in chat at their disposal. History playback, infinite undo, easy import and export of documents are some of the cool stuff it has to offer.

Compared to the original, EL has very short system requirements list, which makes it very easy to deploy. Since it’s written in server-side JavaScript using Node.js, to make it functional for testing/development purposes you’ll need only Node.js, but for everyday/production usage it’s recommended that you use a web server (e.g. Apache or Nginx) and MySQL.


First you’ll need to install dependencies. If you’re using Red Hat based distro (like CentOS or Fedora) you can use yum:

# yum install gzip git-core curl python openssl-devel make gcc gcc-c++

If you’re using Debian based distro (like Ubuntu), you can use apt-get:

# apt-get install gzip git-core curl python libssl-dev build-essential


Download the latest stable version of Node.js, unpack it and compile it:

# tar xf node-v0.6*
# cd node-v0.6*
# ./configure && make && make install

It’s recommended that you create a separate user for EL.

# useradd -m etherpad

Now you can download the latest version of EL and install its dependencies:

# cd /home/etherpad/ && git clone 'git://github.com/ether/etherpad-lite.git'
# ./etherpad-lite/bin/installDeps.sh

At this point you have basic setup for testing EL. To run it, simply execute the startup script (preferably as etherpad user and not as root):

$ ./etherpad-lite/bin/run.sh

By default, EL binds itself to port 9001, so you can use it by opening http://localhost:9001


I’ll assume that you have Nginx and MySQL installed, so I’m not going to explain how to install and configure them. Instead, I’m going to jump right onto the configuration of EL.


Connect to MySQL server and create a database for EL.

# mysql -u root -p
mysql> create database etherpad;
mysql> grant all privileges on etherpad.* to 'etherpad'@'localhost' identified by 'SomePassword';
mysql> exit

Now you can set up the connection string in EL‘s configuration file – settings.json. There are couple of variables you’ll need to change/set. Default values for ip and port are alright, however you’ll have to change dbType from dirty to mysql and, of course, change dbSettings. If you want to restrict access to EL you can uncomment httpAuth variable and enter username and password. Example of settings.json file:

  This file must be valid JSON. But comments are allowed
  Please edit settings.json, not settings.json.template
  //Ip and port which etherpad should bind at
  "ip": "",
  "port" : 9001,
  /* An Example of MySQL Configuration*/
   "dbType" : "mysql",
   "dbSettings" : {
                    "user"    : "etherpad",
                    "host"    : "localhost",
                    "password": "SomePassword",
                    "database": "etherpad"
  //the default text of a pad
  "defaultPadText" : "Welcome to Etherpad Lite!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nEtherpad Lite on Github: http:\/\/j.mp/ep-lite\n",
  /* Users must have a session to access pads. This effectively allows only group pads to be accessed. */
  "requireSession" : false,
  /* Users may edit pads but not create new ones. Pad creation is only via the API. This applies both to group pads and regular pads. */
  "editOnly" : false,
  /* if true, all css & js will be minified before sending to the client. This will improve the loading performance massivly,
     but makes it impossible to debug the javascript/css */
  "minify" : true,
  /* This is the path to the Abiword executable. Setting it to null, disables abiword.
     Abiword is needed to enable the import/export of pads*/
  "abiword" : null,
  /* This setting is used if you need http basic auth */
  //"httpAuth" : "user:pass",
  /* The log level we are using, can be: DEBUG, INFO, WARN, ERROR */
  "loglevel": "INFO"

After editing the configuration file, it’s time to start EL in order to check if everything is in order. Just like before, you just need to execute run.sh script. If you configured everything correctly, EL will start successfully and create single database table namedstore.

Just to make sure, you should set utf8 character set and collation to both database and its table:

# mysql -u root -p
mysql> use etherpad;
mysql> ALTER DATABASE `etherpad` CHARACTER SET utf8 COLLATE utf8_bin;
mysql> exit


To put EL behind reverse proxy (in this case Nginx), you will need an virtualhost that looks something like this:

server {
    listen       80;
    server_name  your.domain.tld;
    access_log   /var/log/nginx/your.domain.tld.log;
    error_log    /var/log/nginx/your.domain.tld.log;
    location / {
        proxy_pass        http://localhost:9001/;
        proxy_set_header  Host $host;
        proxy_buffering   off;

Init script

To make your life easier, you should configure EL to run as a service. If you’re running Red Hat based distro, just copy the init script shown below to /etc/init.d/etherpad, just make sure that you have defined correct paths for variables pathproglogconf andlockfile:

# etherpad-lite - this script starts and stops the etherpad light daemon
# chkconfig: - 64 36
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 2 3 4 6
# Required-Start:
# description: etherpad lite is a collaboration editor
# processname: node
# config: /srv/etherpad-lite/settings.json
# pidfile: none
# lockfile: /var/lock/subsys/etherpad-light
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
progname="Etherpad Lite"
logpath=$(dirname $log)
start() {
        [ -x $prog ] || exit 5
        [ -f $conf ] || exit 6
        [ -d $logpath ] || mkdir $logpath
        [ -f $log ] || touch $log
        chown $user $logpath
        chown $user $log
        echo -n $"Starting $progname: "
        daemon --user=$user "cd $path; $prog $parameter >>$log &"
        [ $retval -eq 0 ] && touch $lockfile
        return $retval
stop() {
        echo -n $"Stopping $progname: "
        killproc $prog
        [ $retval -eq 0 ] && rm -f $lockfile
        return $retval
restart() {
rh_status() {
        status $prog
rh_status_q() {
        rh_status >/dev/null 2>&1
case "$1" in
                rh_status_q && exit 0
                rh_status_q || exit 0
                echo $"Usage: $0 {start|stop|status|restart}"
                exit 2

When you’re done, make the init script executable and start etherpad:

# chmod 755 /etc/init.d/etherpad
# service etherpad start

Init scripts for other distributions can be found here.


Upgrading EL is super easy and it’s done by pulling the changes from git repository:

$ cd /home/etherpad/etherpad-lite/
$ git pull origin

You don’t have to worry about settings.json configuration file. It won’t be overwritten

Wiping a Mac OSX Encrypted USB Disk

I got stuck with a disk which was encrypted with Time Machine and was not able to format it.  A lot of googling did not help. Finally i was able to do it by connecting the disk to a Windows Machine.

Go to Disk Management Delete All Existing Partition, Make sure you are selecting other than Disk0.

You will not be able to delete the EFI Partition. To delete EFI Partition


[step 1] With the USB drive connected, open a command prompt with elevated privileges.

[step 2] Start the disk partition utility by typing diskpart.

[step 3] Type list disk to see all of your connected disks (be sure you’re working on the right disk, if you select the wrong disk you’ll be sorry – see disclaimer). To select a disk type select disk # where # is the disk number you want to delete the EFI partition from.

[step 4] Type select partition # where # is the number of the partition you want to delete.

[step 5] Type delete partition override

That’s it.


GIT cheatsheet



git clone <repo>
  clone the repository specified by <repo>; this is similar to "checkout" in
  some other version control systems such as Subversion and CVS

Add colors to your ~/.gitconfig file:

    ui = auto
  [color "branch"]
    current = yellow reverse
    local = yellow
    remote = green
  [color "diff"]
    meta = yellow bold
    frag = magenta bold
    old = red bold
    new = green bold
  [color "status"]
    added = yellow
    changed = green
    untracked = cyan

Highlight whitespace in diffs

    ui = true
  [color "diff"]
    whitespace = red reverse

Add aliases to your ~/.gitconfig file:

    st = status
    ci = commit
    br = branch
    co = checkout
    df = diff
    dc = diff --cached
    lg = log -p
    lol = log --graph --decorate --pretty=oneline --abbrev-commit
    lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
    ls = ls-files

    # Show files ignored by git:
    ign = ls-files -o -i --exclude-standard


git config -e [--global]
  edit the .git/config [or ~/.gitconfig] file in your $EDITOR

git config --global user.name 'John Doe'
git config --global user.email johndoe@example.com
  sets your name and email for commit messages

git config branch.autosetupmerge true
  tells git-branch and git-checkout to setup new branches so that git-pull(1)
  will appropriately merge from that remote branch.  Recommended.  Without this,
  you will have to add --track to your branch command or manually merge remote
  tracking branches with "fetch" and then "merge".

git config core.autocrlf true
  This setting tells git to convert the newlines to the system's standard
  when checking out files, and to LF newlines when committing in

git config --list
  To view all options

git config apply.whitespace nowarn
  To ignore whitespace

You can add "--global" after "git config" to any of these commands to make it
apply to all git repos (writes to ~/.gitconfig).

git reflog
  Use this to recover from *major* mess ups! It's basically a log of the
  last few actions and you might have luck and find old commits that
  have been lost by doing a complex merge.

git diff
  show a diff of the changes made since your last commit
  to diff one file: "git diff -- <filename>"
  to show a diff between staging area and HEAD: `git diff --cached`

git status
  show files added to the staging area, files with changes, and untracked files

git log
  show recent commits, most recent on top. Useful options:
  --color       with color
  --graph       with an ASCII-art commit graph on the left
  --decorate    with branch and tag names on appropriate commits
  --stat        with stats (files changed, insertions, and deletions)
  -p            with full diffs
  --author=foo  only by a certain author
  --after="MMM DD YYYY" ex. ("Jun 20 2008") only commits after a certain date
  --before="MMM DD YYYY" only commits that occur before a certain date
  --merge       only the commits involved in the current merge conflicts

git log <ref>..<ref>
  show commits between the specified range. Useful for seeing changes from
  git log HEAD..origin/master # after git remote update

git show <rev>
  show the changeset (diff) of a commit specified by <rev>, which can be any
  SHA1 commit ID, branch name, or tag (shows the last commit (HEAD) by default)

  also to show the contents of a file at a specific revision, use 
     git show <rev>:<filename>
  this is similar to cat-file but much simpler syntax.

git show --name-only <rev>
  show only the names of the files that changed, no diff information.

git blame <file>
  show who authored each line in <file>

git blame <file> <rev>
  show who authored each line in <file> as of <rev> (allows blame to go back in

git gui blame
  really nice GUI interface to git blame

git whatchanged <file>
  show only the commits which affected <file> listing the most recent first
  E.g. view all changes made to a file on a branch:
    git whatchanged <branch> <file>  | grep commit | \
         colrm 1 7 | xargs -I % git show % <file>
  this could be combined with git remote show <remote> to find all changes on
  all branches to a particular file.

git diff <commit> head path/to/fubar
  show the diff between a file on the current branch and potentially another

git diff --cached [<file>]
  shows diff for staged (git-add'ed) files (which includes uncommitted git
  cherry-pick'ed files)

git ls-files
  list all files in the index and under version control.

git ls-remote <remote> [HEAD]
  show the current version on the remote repo. This can be used to check whether
  a local is required by comparing the local head revision.

Adding / Deleting

git add <file1> <file2> ...
  add <file1>, <file2>, etc... to the project

git add <dir>
  add all files under directory <dir> to the project, including subdirectories

git add .
  add all files under the current directory to the project
  *WARNING*: including untracked files.

git rm <file1> <file2> ...
  remove <file1>, <file2>, etc... from the project

git rm $(git ls-files --deleted)
  remove all deleted files from the project

git rm --cached <file1> <file2> ...
  commits absence of <file1>, <file2>, etc... from the project


Option 1:

Edit $GIT_DIR/.git/info/exclude. See Environment Variables below for explanation
on $GIT_DIR.

Option 2:

Add a file .gitignore to the root of your project. This file will be checked in.

Either way you need to add patterns to exclude to these files.


git add <file1> <file2> ...
git stage <file1> <file2> ...
  add changes in <file1>, <file2> ... to the staging area (to be included in
  the next commit

git add -p
git stage --patch
  interactively walk through the current changes (hunks) in the working
  tree, and decide which changes to add to the staging area.

git add -i
git stage --interactive
  interactively add files/changes to the staging area. For a simpler
  mode (no menu), try `git add --patch` (above)


git reset HEAD <file1> <file2> ...
  remove the specified files from the next commit


git commit <file1> <file2> ... [-m <msg>]
  commit <file1>, <file2>, etc..., optionally using commit message <msg>,
  otherwise opening your editor to let you type a commit message

git commit -a
  commit all files changed since your last commit
  (does not include new (untracked) files)

git commit -v
  commit verbosely, i.e. includes the diff of the contents being committed in
  the commit message screen

git commit --amend
  edit the commit message of the most recent commit

git commit --amend <file1> <file2> ...
  redo previous commit, including changes made to <file1>, <file2>, etc...


git branch
  list all local branches

git branch -r
  list all remote branches

git branch -a
  list all local and remote branches

git branch <branch>
  create a new branch named <branch>, referencing the same point in history as
  the current branch

git branch <branch> <start-point>
  create a new branch named <branch>, referencing <start-point>, which may be
  specified any way you like, including using a branch name or a tag name

git push <repo> <start-point>:refs/heads/<branch>
  create a new remote branch named <branch>, referencing <start-point> on the
  remote. Repo is the name of the remote.
  Example: git push origin origin:refs/heads/branch-1
  Example: git push origin origin/branch-1:refs/heads/branch-2
  Example: git push origin branch-1 ## shortcut

git branch --track <branch> <remote-branch>
  create a tracking branch. Will push/pull changes to/from another repository.
  Example: git branch --track experimental origin/experimental

git branch --set-upstream <branch> <remote-branch> (As of Git 1.7.0)
  Make an existing branch track a remote branch
  Example: git branch --set-upstream foo origin/foo

git branch -d <branch>
  delete the branch <branch>; if the branch you are deleting points to a
  commit which is not reachable from the current branch, this command
  will fail with a warning.

git branch -r -d <remote-branch>
  delete a remote-tracking branch.
  Example: git branch -r -d wycats/master

git branch -D <branch>
  even if the branch points to a commit not reachable from the current branch,
  you may know that that commit is still reachable from some other branch or
  tag. In that case it is safe to use this command to force git to delete the

git checkout <branch>
  make the current branch <branch>, updating the working directory to reflect
  the version referenced by <branch>

git checkout -b <new> <start-point>
  create a new branch <new> referencing <start-point>, and check it out.

git push <repository> :<branch>
  removes a branch from a remote repository.
  Example: git push origin :old_branch_to_be_deleted

git co <branch> <path to new file>
  Checkout a file from another branch and add it to this branch. File
  will still need to be added to the git branch, but it's present.
  Eg. git co remote_at_origin__tick702_antifraud_blocking

git show <branch> -- <path to file that does not exist>
  Eg. git show remote_tick702 -- path/to/fubar.txt
  show the contents of a file that was created on another branch and that
  does not exist on the current branch.

git show <rev>:<repo path to file>
  Show the contents of a file at the specific revision. Note: path has to be
  absolute within the repo.


git merge <branch>
  merge branch <branch> into the current branch; this command is idempotent
  and can be run as many times as needed to keep the current branch
  up-to-date with changes in <branch>

git merge <branch> --no-commit
  merge branch <branch> into the current branch, but do not autocommit the
  result; allows you to make further tweaks

git merge <branch> -s ours
  merge branch <branch> into the current branch, but drops any changes in
  <branch>, using the current tree as the new tree


git cherry-pick [--edit] [-n] [-m parent-number] [-s] [-x] <commit>
  selectively merge a single commit from another local branch
  Example: git cherry-pick 7300a6130d9447e18a931e898b64eefedea19544

git hash-object <file-path>
  get the blob of some file whether it is in a repository or not

Find the commit in the repository that contains the file blob:

    git log --pretty=format:'%T %h %s' \
    | while read tree commit subject ; do
        if git ls-tree -r $tree | grep -q "$obj_blob" ; then
            echo $commit "$subject"

WARNING: "git rebase" changes history. Be careful. Google it.

git rebase --interactive HEAD~10
  (then change all but the first "pick" to "squash")
  squash the last 10 commits into one big commit


git mergetool
  work through conflicted files by opening them in your mergetool (opendiff,
  kdiff3, etc.) and choosing left/right chunks. The merged result is staged for

For binary files or if mergetool won't do, resolve the conflict(s) manually
and then do:

  git add <file1> [<file2> ...]

Once all conflicts are resolved and staged, commit the pending merge with:

  git commit


git fetch <remote>
  update the remote-tracking branches for <remote> (defaults to "origin").
  Does not initiate a merge into the current branch (see "git pull" below).

git pull
  fetch changes from the server, and merge them into the current branch.
  Note: .git/config must have a [branch "some_name"] section for the current
  branch, to know which remote-tracking branch to merge into the current
  branch.  Git 1.5.3 and above adds this automatically.

git push
  update the server with your commits across all branches that are *COMMON*
  between your local copy and the server.  Local branches that were never
  pushed to the server in the first place are not shared.

git push origin <branch>
  update the server with your commits made to <branch> since your last push.
  This is always *required* for new branches that you wish to share. After
  the first explicit push, "git push" by itself is sufficient.

git push origin <branch>:refs/heads/<branch>
  E.g. git push origin twitter-experiment:refs/heads/twitter-experiment
  Which, in fact, is the same as git push origin <branch> but a little
  more obvious what is happening.


git revert <rev>
  reverse commit specified by <rev> and commit the result.  This does *not* do
  the same thing as similarly named commands in other VCS's such as "svn
  revert" or "bzr revert", see below

git checkout <file>
  re-checkout <file>, overwriting any local changes

git checkout .
  re-checkout all files, overwriting any local changes.  This is most similar
  to "svn revert" if you're used to Subversion commands

Fix mistakes / Undo

git reset --hard
  abandon everything since your last commit; this command can be DANGEROUS.
  If merging has resulted in conflicts and you'd like to just forget about
  the merge, this command will do that.

git reset --hard ORIG_HEAD or git reset --hard origin/master 
  undo your most recent *successful* merge *and* any changes that occurred
  after.  Useful for forgetting about the merge you just did.  If there are
  conflicts (the merge was not successful), use "git reset --hard" (above)

git reset --soft HEAD^
  forgot something in your last commit? That's easy to fix. Undo your last
  commit, but keep the changes in the staging area for editing.

git commit --amend
  redo previous commit, including changes you've staged in the meantime.
  Also used to edit commit message of previous commit.


test <sha1-A> = $(git merge-base <sha1-A> <sha1-B>)
  determine if merging sha1-B into sha1-A is achievable as a fast forward;
  non-zero exit status is false.


git stash
git stash save <optional-name>
  save your local modifications to a new stash (so you can for example
  "git svn rebase" or "git pull")

git stash apply
  restore the changes recorded in the stash on top of the current working tree

git stash pop
  restore the changes from the most recent stash, and remove it from the stack
  of stashed changes

git stash list
  list all current stashes

git stash show <stash-name> -p
  show the contents of a stash - accepts all diff args

git stash drop [<stash-name>]
  delete the stash

git stash clear
  delete all current stashes


git remote add <remote> <remote_URL>
  adds a remote repository to your git config.  Can be then fetched locally.
    git remote add coreteam git://github.com/wycats/merb-plugins.git
    git fetch coreteam

git push <remote> :refs/heads/<branch>
  delete a branch in a remote repository

git push <remote> <remote>:refs/heads/<remote_branch>
  create a branch on a remote repository
  Example: git push origin origin:refs/heads/new_feature_name

git push <repository> +<remote>:<new_remote>
  replace a <remote> branch with <new_remote>
  think twice before do this
  Example: git push origin +master:my_branch

git remote prune <remote>
  prune deleted remote-tracking branches from "git branch -r" listing

git remote add -t master -m master origin git://example.com/git.git/
  add a remote and track its master

git remote show <remote>
  show information about the remote server.

git checkout -b <local branch> <remote>/<remote branch>
    git checkout -b myfeature origin/myfeature
    git checkout -b myfeature remotes/<remote>/<branch>

  Track a remote branch as a local branch. It seems that
  somtimes an extra 'remotes/' is required, to see the exact
  branch name, 'git branch -a'.

git pull <remote> <branch>
git push
  For branches that are remotely tracked (via git push) but
  that complain about non-fast forward commits when doing a
  git push. The pull synchronizes local and remote, and if
  all goes well, the result is pushable.

git fetch <remote>
  Retrieves all branches from the remote repository. After
  this 'git branch --track ...' can be used to track a branch
  from the new remote.


git submodule add <remote_repository> <path/to/submodule>
  add the given repository at the given path. The addition will be part of the
  next commit.

git submodule update [--init]
  Update the registered submodules (clone missing submodules, and checkout
  the commit specified by the super-repo). --init is needed the first time.

git submodule foreach <command>
  Executes the given command within each checked out submodule.

Removing submodules

   1. Delete the relevant line from the .gitmodules file.
   2. Delete the relevant section from .git/config.
   3. Run git rm --cached path_to_submodule (no trailing slash).
   4. Commit and delete the now untracked submodule files.

Updating submodules
  To update a submodule to a new commit:
    1. update submodule:
        cd <path to submodule>
        git pull
    2. commit the new version of submodule:
        cd <path to toplevel>
        git commit -m "update submodule version"
    3. check that the submodule has the correct version
        git submodule status
  If the update in the submodule is not committed in the
  main repository, it is lost and doing git submodule
  update will revert to the previous version.


git format-patch HEAD^
  Generate the last commit as a patch that can be applied on another
  clone (or branch) using 'git am'. Format patch can also generate a
  patch for all commits using 'git format-patch HEAD^ HEAD'
  All page files will be enumerated with a prefix, e.g. 0001 is the
  first patch.

git format-patch <Revision>^..<Revision>
  Generate a patch for a single commit. E.g.
    git format-patch d8efce43099^..d8efce43099
  Revision does not need to be fully specified.

git am <patch file>
  Applies the patch file generated by format-patch.

git diff --no-prefix > patchfile
  Generates a patch file that can be applied using patch:
    patch -p0 < patchfile
  Useful for sharing changes without generating a git commit.


git tag -l
  Will list all tags defined in the repository.

git co <tag_name>
  Will checkout the code for a particular tag. After this you'll
  probably want to do: 'git co -b <some branch name>' to define
  a branch. Any changes you now make can be committed to that
  branch and later merged.


git archive master | tar -x -C /somewhere/else
  Will export expanded tree as tar archive at given path

git archive master | bzip2 > source-tree.tar.bz2
  Will export archive as bz2

git archive --format zip --output /full/path master
  Will export as zip

Git Instaweb

git instaweb --httpd=webrick [--start | --stop | --restart]

Environment Variables

  Your full name to be recorded in any newly created commits.  Overrides
  user.name in .git/config

  Your email address to be recorded in any newly created commits.  Overrides
  user.email in .git/config

  Location of the repository to use (for out of working directory repositories)

  Location of the Working Directory - use with GIT_DIR to specifiy the working
  directory root
  or to work without being in the working directory at all.

Changing history

Change author for all commits with given name

  git filter-branch --commit-filter '
          if [ "$GIT_COMMITTER_NAME" = "<Old Name>" ];
                  GIT_COMMITTER_NAME="<New Name>";
                  GIT_AUTHOR_NAME="<New Name>";
                  GIT_COMMITTER_EMAIL="<New Email>";
                  GIT_AUTHOR_EMAIL="<New Email>";
                  git commit-tree "$@";
                  git commit-tree "$@";
          fi' HEAD

How to Create a SSL Certificate on Apache for CentOS 6

About Self-Signed Certificates

A SSL certificate is a way to encrypt a site’s information and create a more secure connection. Additionally, the certificate can show the virtual private server’s identification information to site visitors. Certificate Authorities can issue SSL certificates that verify the virtual server’s details while a self-signed certificate has no 3rd party corroboration.

Step One—Install Mod SSL

In order to set up the self signed certificate, we first have to be sure that Apache and Mod SSL are installed on our VPS. You can install both with one command:

yum install mod_ssl


Step Two—Create a New Directory

Next, we need to create a new directory where we will store the server key and certificate

mkdir /etc/httpd/ssl


Step Three—Create a Self Signed Certificate

When we request a new certificate, we can specify how long the certificate should remain valid by changing the 365 to the number of days we prefer. As it stands this certificate will expire after one year.

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/httpd/ssl/apache.key -out /etc/httpd/ssl/apache.crt

With this command, we will be both creating the self-signed SSL certificate and the server key that protects it, and placing both of them into the new directory.

This command will prompt terminal to display a lists of fields that need to be filled in.

The most important line is “Common Name”. Enter your official domain name here or, if you don’t have one yet, your site’s IP address.

You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
Country Name (2 letter code) [AU]:US
State or Province Name (full name) [Some-State]:New York
Locality Name (eg, city) []:NYC
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Awesome Inc
Organizational Unit Name (eg, section) []:Dept of Merriment
Common Name (e.g. server FQDN or YOUR name) []:example.com                  
Email Address []:webmaster@awesomeinc.com


Step Four—Set Up the Certificate

Now we have all of the required components of the finished certificate.The next thing to do is to set up the virtual hosts to display the new certificate.

Open up the SSL config file:

 vi /etc/httpd/conf.d/ssl.conf

Find the section that begins with <VirtualHost _default_:443> and make some quick changes.

Uncomment the DocumentRoot and ServerName line and replace example.com with your DNS approved domain name or server IP address (it should be the same as the common name on the certificate):

 ServerName example.com:443

Find the following three lines, and make sure that they match the extensions below:

SSLEngine on
SSLCertificateFile /etc/httpd/ssl/apache.crt
SSLCertificateKeyFile /etc/httpd/ssl/apache.key

Your virtual host is now all set up! Save and Exit out of the file.

Step Five—Restart Apache

You are done. Restarting the Apache server will reload it with all of your changes in place.

 /etc/init.d/httpd restart

In your browser, type https://youraddress to view the new certificate.