3). Main principles to use GIT for the SURFEX code



- REGISTRATION / AUTHORISATION:

1. First, a request must be send by email to surfex-support@meteo.fr in which you explain that you want to have access to the GIT repository. Please explain your motivations, and why the Open-SURFEX version is not sufficient for you.

2. If the request is accepted, to have to the GIT repository, first, you must open an account on https://opensource.umr-cnrm.fr/

3. When you receive the confirmation that you account is open, inform surfex-support@meteo.fr. We will add you as member of the Surfex_Git2 project.

4. When you have confirmation of (3), finally, you need to be identified by the server. For that, send your SSH public key to operator@meteo.fr.
This key is available in the directory $HOME/.ssh, file id_rsa.pub.
If this file doesn’t exist, you can create it with the command: ssh-keygen



- CLONING THE SURFEX GIT REPOSITORY:

To create your own SURFEX GIT repository, first create a directory, SURFEX_GIT for example. Go into this directory and type:

To get the code as reader only via GIT:

git clone ssh://reader097@git.umr-cnrm.fr/git/Surfex_Git2.git

To get the code and manage a branch:

git clone ssh://admin097@git.umr-cnrm.fr/git/Surfex_Git2.git

This allows you to access to the whole remote repository for the SURFEX project.

By default, you first get to the master branch (= trunk in SVN).


- BASIC GIT COMMANDS:

Basic commands to access, create and modify branches:

To send modifications to the GIT server, you will need to be identified. For that, use the command "config". This command modifies the file $HOME/.gitconfig:

  • git config —global user.name "[your name]": registers your name
  • git config —global user.email "[your e-mail adress]": registers your e-mail adress
  • git config —global push.defaut simple: sets the default type of communication with the GIT server (git will ask you to set it at first time you will try to push some modifications to the server).
  • etc.

To browse in branches:

  • git branch -a: lists all local and remote branches
  • git checkout [existing branch name]: moves to the specified branch (updates the working directory)
  • git branch [new branch name]: create a new branch from the branch and state you are positioned on at the moment of this creation.
  • git branch -d [existing branch name]: deletes the speficied branch.

To download last changes from the GIT server:

  • git fetch: downloads new changes from the remote repository, but doesn’t merge them locally.
  • git pull: for the branch you are locally positioned on, downloads new changes from the remote repository and merges them locally.

To make and see changes:

  • git status: lists all new of modified files to be commited
  • git diff: shows file differences not yet commited
  • git add [file]: snapshots the file in preparation for versioning
  • git commit -m "[descriptive message]": records the files modifications permanently in version history
  • git log: lists version history for the current branch
  • git show [commit]: outputs metadata and content changes of the specified commit
  • git push [alias] [branch]: uploads all local branch commits to the GIT server.

To merge another branch with the current branch:

  • git merge [branch]: combines the specified branch’s history into the current branch.

To go little further:

GIT CHEAT SHEET