Ca va ENCORE parler de bits!

2014-02-23  |  Tips 'n' Tricks  |  git project management repositories

As with the previous article on project management with SVN. We will, this time with GIT, see a simple process of project management.

Note : If your are looking to install your GIT server, look at this page How to install GIT with SSH [...].
Note : To train yourself, you can open a free repository on This tutorial is develop around the free repository ex-project-management.

Before starting

Before you begin, it is important to know that Git is significantly different from SVN. Git provides a concept of "local working".

  • When working with GIT, all actions are first made ​​on a local space,
  • In a second time, you must send this local work on the remote server (the main remote server is called "origin").

Cloning an empty repository

Two ways to initialize a new repository to work in.

  • If you have no file already ready to push on the repo

First, clone the repository

git clone

Now, you can work locally

touch // create a new file
echo "This is the readme file." > // add content in the file
git add // add the ne file in your local
git commit -m "Initiale commit." // commit your local work

And finally, push your work on the repository

git push -u origin master // send your local work to the repository
  • If you have files already ready to push on the repo

Place in your directory containing your files

cd ex-project-management

Now, initialize the git config files

git init // create the git config directory ".git"
git add . // to add all files
git commit -m "Initiale commit" // commit locally
git remote add origin // configure git remote, the origin url server

And finally, push your work on the repository

git push -u origin master // Send your local work to the repository

Some information about these first commands

About the ".git" directory

  • It contains the configuration files,
  • It is automatically created when you do a "git clone" command (after a "git clone", you don't have to make "git remote" to specify origin remote),
  • It stock info about local and remote server.
Note : In this tutorial, we will not discuss the use of multi-remote.

The establishment of branches in GIT

As for SVN, the establishment of branches request to establish a hierarchy. However, with GIT, it is much less restrictive.

So before creating a branch, make sure to be in good parent branch.

git branch // allow to know the current branch where we are
git checkout BRANCH_NAME // allow to move the branch BRANCH_NAME

To create a new branch simply use following commands

git branch NEW_BRANCH_NAME // to create the new branch
git checkout NEW_BRANCH_NAME // to make the new branch as current working space

Or use this line to make this two actions in a single time

git checkout -b NEW_BRANCH_NAME

Because the branch is make locally, we have to push it on origin

git push origin NEW_BRANCH_NAME
Note : It is possible to add the character '/' in the name of your branches. This will allow you to add a notion of directories to your branches. For example version1/master, version2/master.

Now we will see how integrating a branch in another via "git merge". Like the establishment of branches, it is important to know where you are. To integrate a branch in another, it must be placed in the branch that will receive the second.

git merge BRANCH_NAME_TO_INTEGRATE // will merge BRANCH_NAME_TO_INTEGRATE in the current branch

Now the working case

When i am working with PyroCMS, i have facing that the developement team make new realese very fast. And i have to prepare project to be able to evolve, following PyroCMS release.

The other role to get a well organized is to be able to maintain older projets. Not every clients would change their habits, and sometime you have to work with older release to make patch or new features.

By example, if have to make new module for PyroCMS. I will open a new repository, and make some branches based on the PyroCMS version i will use.

git clone
git checkout -b 2.1.5/master
git push origin 2.1.5/master
git checkout -b 2.1.5/dev
git push origin 2.1.5/dev

Now, i will simply work in the dev branch. When I finished, I go back in my work 2.1.5/master branch and the master branch.

git checkout 2.1.5/master // go to 2.1.5/master
git merge 2.1.5/dev // merge 2.1.5/dev to 2.1.5/master
git push // send last merge
git checkout master // go to master
git merge 2.1.5/master // merge 2.1.5/master to master
git push // send last merge

Now i got the latest version of my work in the master branch. To save this version, i make a tag.

git tag -a v1.0.0-Pyro2.1.5 -m 'First release on PyroCMS 2.1.5'
git push origin v1.0.0-Pyro2.1.5 // send to origin the tag

At this point, several things are possible:

  • The developments are finished. we can maximize my GIT server space by removing branches dev (2.1.5/dev) [You can even remove the 2.1.5/master branch if you really need]. If developments should resume, simply recreate these branches starting from the tag v1.0.0-Pyro2.1.5.
  • The developments begin on a more recent version of PyroCMS. Then just created the PYRO_VERSION/master and PYRO_VERSION/dev branches and follow to the previous methodology to realize the new merges and tags.

Bulk commands

Delete a local branch

git branch -d BRANCH_NAME

Delete a branch from origin server

git push origin :BRANCH_NAME
git branch -d BRANCH_NAME // you have to delete the local branch too

To archive a project

git archive master --format=zip --output=../
git archive master --format=tar --output=../archive-module.tar

Resources, the reference website on GIT, a very good tips and tricks tutorial


Share this article :

blog comments powered by Disqus

© 2012-2017 Ca va ENCORE parler de bits! All Rights Reserved.