« Torna a 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 user.email "me@here.com"
  • Name:
git config --global user.name "Your Name"

Set SSH keys and add it to the GitHub account. For help, see GitHub's article https://help.github.com/articles/generating-ssh-keys

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@github.com/your-github-username/liferay-portal.git
git clone ssh://git@github.com/your-github-username/liferay-plugins.git

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://github.com/liferay/liferay-portal.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 Allegati
35105 Visualizzazioni
Media (3 Voti)
La media del punteggio è 5.0 stelle su 5.
Commenti Autore Data
While Configuring local master, using git... Tejas Kanani 12 settembre 2012 20.09
Hi Tejas, the point of that command is to... Oussama Denden 27 dicembre 2012 1.34
If I understand the goals, the step "Configure... Mauro Mariuzzo 25 febbraio 2013 0.35

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 ?
Inviato il 12/09/12 20.09.
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
Inviato il 27/12/12 1.34.
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?
Inviato il 25/02/13 0.35.