Liferay is a Gartner Magic Quadrant Leader for the Sixth Year! Find out why
« Back to Contributing

Contribute using Git and GitHub

Initial setup and configuration #

GitHub Account #

Make an account on GitHub. A variety of plans are available, but a free account works just fine.

Set up Git #

Install Git following instructions from: Generating SSH Keys

Setup your personal info in local Git repo:

  • Email:
git config --global ""
  • Name:
git config --global "Your Name"

Set SSH keys and add it to the GitHub account. For help, see GitHub's article

Retrieve Liferay source code #

Fork Liferay repositories #

Fork both the Liferay Portal and Liferay Plugins repositories to your GitHub account. Do this by visiting the repositories at the links below and then click the "Fork" button. You must be signed in to fork the repositories.

Clone forked repositories #

Clone your own forked GitHub repos. Go to a location on your computer that you wish to have a copy of the Liferay Portal and Liferay Plugins source stored. This could be a "Development" directory within your user's home directory, for example. Once in this location, issue the following git commands to clone your forked repositories to your computer:

git clone ssh://
git clone ssh://

This may take a long time depending on your network connectivity -- grab a cup of coffee and wait it out.

Once it completes, you will see two new directories - liferay-portal and liferay-plugins. Inside each of these directories is the source code for each.

Configure remote upstream #

Set the remote upstream repository for both liferay-portal and liferay-plugins. Run the command below inside the liferay-portal directory. Then, change "liferay-portal.git" to "liferay-plugins.git" and run the command in the liferay-plugins directory, too.

git remote add upstream git://

Configure local master #

Create local master branch from the upstream. Run the command below inside the liferay-portal directory. Then, change to the liferay-plugins directory and run the same command.

git checkout -b master "upstream/master"

Now we have 3 repositories each for liferay-portal and liferay-plugins: local (on your computer), origin (your fork on GitHub) and the upstream (the main owned by Liferay on GitHub).

Sync changes from upstream #

If the main repository changes, you will need to sync changes from upstream. You can accomplish this with the following commands:

  • Get all the updates from upstream
git fetch upstream
  • Switch to the master branch
git checkout master
  • Rebase the master branch. With rebase, all local commits are stashed and applied after the fetch
git pull --rebase upstream master
  • Push the updates to origin
git push origin master

Now the local, origin, and upstream repositories are all current

0 Attachments
Average (2 Votes)
The average rating is 5.0 stars out of 5.
Threaded Replies Author Date
While Configuring local master, using git... Tejas Kanani September 12, 2012 8:09 PM
Hi Tejas, the point of that command is to... Oussama Denden December 27, 2012 1:34 AM
If I understand the goals, the step "Configure... Mauro Mariuzzo February 25, 2013 12:35 AM

While Configuring local master, using
git checkout -b master "upstream/master"

getting below error.
fatal: git checkout: updating paths is incompatible with switching branches.
Did you intend to checkout 'upstream/master' which can not be resolved as commit?

Any idea what is going wrong ?
Posted on 9/12/12 8:09 PM.
Hi Tejas,
the point of that command is to create a new branch in which u would do whatever u want to do with liferay source code so doing something like git checkout -b fix_something would be enough
Posted on 12/27/12 1:34 AM.
If I understand the goals, the step "Configure local master" is a way to have a branch of origin with the contributed code.

So we can do:
git checkout -b "branch name" "origin/master"

And to contribute the code we have to create a pull from that branch.

I'm right?
Posted on 2/25/13 12:35 AM.