User Tools

Site Tools


git

Using Git

Git has been chosen as source code management [SCM] management system. Git has become a standard and is well document on Internet. For a full documentation follow this link.

The Git server on SourceSup contains all the models composing MORCE as well as the IO systems. Once downloaded you also obtain the tools needed to compile the model and configuration files for its execution. The only element which is assumed to exist on the computer on which it will be executed is OASIS3_mct.

Configure Git for your application

The first step is to allow an SSH access to the SourceSup of RENATER by depositing there your public SSH key.

This can be done under thumbnails My Page/My Account. Once you have uploaded you SSH key it may take 1 hour until it becomes active. So please be patient.

The second step is to configure Git on the computer on which you will be managing the code. Two file are key here :

  • ${HOME}/.gitconfig : provides some standard information and aliases.
  • ${HOME}/.gitignore : tells git which files and directories should not be part of the code. This is only used of the code you use doen not have its own .gitignore.

.gitconfig

This file is mainly there to make your life simpler.

Sample file :

[user] 
name = My Name on Source Sup
email = name@email.com
[alias]
st = status
co = checkout
br = branch
up = rebase
ci = commit
[core]
editor = vi
excludesfile = ~/.gitignore
[remote "regipsl"]
url = git+ssh://git@git.renater.fr:2222/morcemed.git

This Git configuration file also defines the remote repository “regipsl” and thus facilitates all the future steps.

.gitignore

A sample file :

# Mac OS X
*.DS_Store

# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
project.xcworkspace/
xcuserdata/
.host_target

# Generated files
*.[oa]
*.pyc
*.exe
*.mod

# Backup files
*~.nib
*.*~
*~

# Overall RegIPSL
RegIPSL/bin/
RegIPSL/lib/
RegIPSL/include/

It is important that executable (bin/), libraries (lib/, *.mod and *.[ao]) and backup files (*~) be excluded from code management. A much more complete version of the .gitignore is now included in the distribution of RegIPSL and will override what the user specifies.

Obtain your version of MORCE

Once git has been configured (see Using Git) retireving your working copy of the model is done in 2 simple steps :

  • git init 

    Creates your local Git infrastructure in the directory into which the model will be uploaded.

  • git pull regipsl 

    Extracts from the repository the current master version of the model and installs it in your directory.

Do your own developments on the code

In the directory you have creating by pulling the latest version of regipsl, you can change the code as you wish. You can locally keep a trace of what you have changed. Once you have reached a version which you wish to share with the other users you can easily upload your modifications onto the repository on SourceSup.

The following commands are essential for keeping track of your developments. It is assumed that these commands are executed at the root of the Git directory.

 git add .

This command tells Git that you have made a number of changes and added or deleted some files. This does not yet save the changes but only ensures that the new files are followed for changes and committed when needed. This staging of the changes allows to group them in logical units. Thus it is important to perform this command after any major changes to the code which affects the structure of the working copy you are working on.

 git commit .

This is the command which saves and commits your changes. It will ask you for some description of the changes. Once you have committed these changes they are tagged in the development tree and allows others to follow your developments and facilitates merger with other changes.

 git status

shows which files have changed and which are new and how git will deal with them. It will tell you if the files are being followed and thus will be committed or on the contrary are not being followed and thus will not be added to the next commit. This is an important command to execute before any commit to ensure that you will not upload some temporary files and that all those you have added or changed are ready to be committed.

 git log

Allows you view what you have committed to the branch on which you are working.

Contribute your developments to the repository

Once you are happy with your development, you can upload them to the repository at SourceSup. When you do this all commits and adds are uploaded and thus others can exactly follow the changes you have done. This is essential knowledge as it allows to manager easier merges with other changes.

You need to check that remote repository you defined in .gitconfig really exists :

git remote -v 

should show that you are connected to git server of RENATER using the ssh protocol.

First you make sure that your version is up to date with the current master branch.

 git pull regipsl 

will merge the changes which have been made on the repository of SourceSup into your branch.

Once your version is up to date all is uploaded with the following command :

 git push regipsl 

Should a conflict occur during the merge of the trunk with your development, there are a few tools you can use. First get a clear vision where the merge is blocked by a conflict :

 git mergetool 

This will present the 2 version (the head of the development tree and you current version) and the conflicting part. You can then in the GUI of that tool resolve the conflicts by selecting the sections which you want to keep and those which should be deleted. Once this is done and saved, you need to commit them to your branch. This is done with the command :

 git commit -am 'Conflicts resolved' 

Once this has been completed with success you can upload your developments with the “git push” described above.

git.txt · Last modified: 2017/07/12 20:54 by jan.polcher@lmd.jussieu.fr