Trabajar con git y github

From Joomla! Documentation

Revision as of 14:56, 12 November 2015 by Abulafia (talk | contribs) (Created page with "Trabajar con git y github")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Other languages:
Deutsch • ‎English • ‎Nederlands • ‎español • ‎français • ‎português do Brasil • ‎русский
Documentation all together tranparent small.png
Under Construction

This article or section is in the process of an expansion or major restructuring. You are welcome to assist in its construction by editing it as well. If this article or section has not been edited in several days, please remove this template.
This article was last edited by Abulafia (talk| contribs) 8 years ago. (Purge)


This document will provide information about contributing to the Joomla! CMS with help of Git and GitHub. If you like to made a simple change (one file only), it is easier to use this documentation: Using the Github UI to Make Pull Requests If you like to add more complex changes or you're just interested in this, keep reading!

What are Git and GitHub?

Git is a distributed version control system. It is a system that records changes in files, and keep this changes in history. So you can always look back to an earlier version of you're code and restore changes if you like. Because of the history, Git is very useful when you work with many people together on the same project.

On this moment GitHub can be used. GitHub is an website, what helps manage Git Projects in a visual way. As owner of a project you can change the code, and compare different versions. As user of the project you can contribute by making an Pull Request. A Pull request is a request to pull some code in that project. You're offering a piece of code, what can be a solution for a bug for example, and asking if the Project owner(s) like to use it. If the owner likes it, he can merge (add) it to his project.

Joomla! uses GitHub and Git to maintain it's code. So everyone can contribute to Joomla! if they like to. The URL to the Joomla! CMS Project on GitHub is:

Getting Started

Sign up on GitHub and install Git

First, you will need to register at GitHub. It's free and very easy to do, just follow the provided steps.

One we are signed up, we need to install Git. The latest version of Git can be found on Download and open the installer. Git is an CLI program, CLI mean Command Line Interface. At the begin this can be confusing and a little bit scared. There is no need for that, this document will lead you to the whole process.

If you're not an advanced user you can just run the installer and press the "next" button until the program will install. Git won't damage you're system, and later you can remove it just like other programs if you like too.

Once we installed Git, we open the program called "Git Bash", and a command line will be opened. We going to tell Git our name and email adres. Git will use this information when we contribute to a project. With the following commands we give Git that information:

git config --global "Your name"
git config --global

In the above commands, and all other commands given in this documentation, each line is a new command. So you type the fist line, presses enter and then type the second line and press enter.

We are now ready to use Git, and go farther with setting up our test installation.

Setting up a test installation

For our test installation we need a program that can simulate a webserver. So we can install and run Joomla! on our computer. There are a lot of program witch can do that. For example MAMP or XAMPP. Download an install one of them.

After the installation of such a program (I use MAMP in this documentation), we going to install the latest version of Joomla!. In our case, the latest version of Joomla! is not the last stable release. The last version of Joomla! is the staging branch on GitHub. First, let me explain a little bit more about GitHub.

Fork and clone Joomla!

On GitHub you can find projects, so called Repositories. Inside a project you can made several version, such a version is called a Branch. Joomla! has the following branches:

  • Staging: This branch contains the latest bug fixes and new features of Joomla!
  • Master: This branch is the current stable version of Joomla!
  • 3.5-dev This branch contains the files for Joomla! 3.5, witch is not stable at the moment of writing.

On our test location we going to use the Staging branch. But if we should use this branch directly we have problem. We can not modify this branch because we are not the owner of it. What we going to do, is making a copy of it, on GitHub this is called a Fork. We are the owner of that copy so we can modify it, and after modifying we compare our fork with the original project. At that moment we can make a Pull Request for the changes we made. More about that later in this documentation. You can Fork a branch by press the Fork button on the Joomla! CMS Github Repository. This button is located at the right top of the page.


After forking, we are going to install Joomla! on our local Web Server. Go to the folder were you can run files on you web server. Most of the program use a folder called htdocs. Once we are inside that folder, press the right mouse button an click on: "Git Bash Here". The command line will open for this location.

Type the following command to download the files form your Fork of the Joomla! CMS your computer. Please replace username with the username you are using on GitHub.

git clone

For all commands given in this documentation, you have to open Git via the above described steps. Please remember that for other commands in this documentation.

Once Git is ready, open your browsers and go to the installation on you localhost. Mostly the URL is something like: http://localhost/joomla-cms. You will now see the default Joomla! installation process.

Install Joomla!

The installation of Joomla! for our local test installation is almost the same as and regular installation. There are a two little difference.

For the database settings, the password and username are default. So mostly the username is root and the password is also root or there is no password. If your still can't connect to the database, look in the manual for you local webserver for the username and password.

The last difference is the last step of the installation. Normally we must delete the installation folder to go further to the back-end or front-end of Joomla!. For a test installation we can skip this part, and we can directly go the back-end or front-end. Don't removing the instillation folder can be very useful when we have to install Joomla again.

Make your changes

Now it is time to made our file change to Joomla!. All changes we make, will be registered and monitored by Git. At any moment you can type the command git status to see witch files are modified or untracked. Untracked means that the file on that location is new for Git.

If you made a mistake or like to restore a file you can use this command:

git checkout path/to/file

If you like to remove all changes you made you can use the following commands:

git checkout .
git clean -f -d

The first command reset all file, and the second command removes untracked files and folders.

Public our changes on GitHub

Push the change to our fork

After making our changes, we have upload our changes to our repository on GitHub. After that, we can make a pull request with our changes.

Upload our changes is called push in Git terms. But before we can do that, we have to do something very important. We must create a new branch for our changes (A branch is a version of our project, remember?). If we don't do that and made our change directly to the staging branch, the first time there won't be a problem. But if we made changes for the second time, and the change we made the first time are not merged yet, all that changes will registered too as new changes.

So the first command we are going to run will create a new branch, to prevent the above described problem. Replace name-new-branch with the name of the new branch. This name must be short, and can only contain lower case letters, number and do NOT have space. Instead of spaces use - (minus)

git checkout -b name-new-branch

The next command tells git that all made changes are good, and are ready to commit.

git add --all

The following command add our change to the branch. Please replace message with a short description of your changes. This description will be the title of the pull request we are going to make.

git commit -m "description"

The final command will push (upload) the changes to our fork. Pleas replace name-new-branch with the name of the branch you made a few steps above.

git push origin name-new-branch

Compare forks and make a pull request

After pushing our change to GitHub, go to your fork of the Joomla! CMS.

Extra information

Because the staging version of Joomla! can change any moment, it is very useful to have the possibility for keeping our fork up-to-date. We can do that by adding a remote to our forked project:

git remote add upstream

We now added a remote called "upstream". With the following command, Git will search for new contribution (commits) in the staging branch we don't have in our fork. If it found some, it will add them to our fork:

git pull upstream staging

The changes are now only made on our local fork. To upload them to GitHub use the following command:

git push