Skip to content

Git express tutorial

yannouk edited this page Oct 25, 2012 · 4 revisions

Table of Contents

How Seizam git is organized ?

2 branches:

  • Main
    • this is the current dev branch, everyone work on it
  • Release
    • this branch contain the revision used in production (on Grodoudou server)
    • DO NOT DEVELOP ON THIS BRANCH!!!

Snapshot a new version

  • First, tag the master branch:
 git checkout master
 git pull
 git tag vX.X.X
 git push --tag
  • Then, merge it into release branch:
 git checkout release
 git merge vX.X.X
 git push

Rename a tag

 git tag new_tag old_tag
 git push --tags

Now, there is a new tag on same commit as the old. Last step is to remove the old tag.

Remove a tag

 git push origin :refs/tags/old_tag
 git tag -d old_tag

Create a branch

Local

 git branch BRANCHNAME

Remote

 git push origin BRANCHNAME

Delete a branch

Local

 git branch -d BRANCHNAME

Remote

 git push origin :BRANCHNAME

Installation

  • In Ubuntu:
    apt-get install git-core

Configuration

After installing Git, please set your username and a email adress, with the following commands

 git config --global user.name "YannoukForExample"
 git config --global user.email [email protected]

Create your local repository and get the current trunk version

Open a terminal and go where you want to store the revision on your hard disk, for example:

 cd /var/www

Now download from github server, by replacing "yannouk" by YOUR username (your github password will be asked):

 git clone https://[email protected]/Seizam/seizamcore

The git clone command automatically sets up your local master branch to track the remote master branch on the server you cloned from.

Get the latest revision from the remote repository

 git pull

Work on files

After editing/creating a file, you have to stage then by using the "add" command:

 git add benchmarks.rb

You can follow the change you made since the last commit / pull

 git status

will output something like

  •  On branch master
  •  Changes to be committed:
  •    (use "git reset HEAD <file>..." to unstage)
  • 	new file:   README
  • 	modified:   benchmarks.rb
  •  Changed but not updated:
  •    (use "git add <file>..." to update what will be committed)
  • 	modified:   benchmarks.rb
In this example, you created README and edited benchmarks.rb, then added them, then you edited benchamrks.rb again, so you need to "git add" it again before committing.

When you are ready to revision, run this command without forgetting to speak about your revision:

 git commit -m "I made incredible things in this revision, the power of god is in mine."

Remember that any files you have created or modified, that you haven’t run "git add" on since you edited them, won’t go into this commit. They will stay as modified files on your disk. The following command will automatically "add" file already known in previous revision (=don't work for a newly created file) before commiting:

 git commit -a -m 'added new benchmarks'

Push to the remote repository

With the commit command, the changes are stored locally. You have to run this to push your work back up to the server:

 git push origin master

Undo any changes since last commit

/!\ use with caution

 git reset --hard

More examples

http://schacon.github.com/git/everyday.html

Clone this wiki locally