Charles Troupin edited this page Jun 22, 2017 · 5 revisions

Git is a version control system (VCS).


The procedure is described for Linux, Mac and Windows on the main git documentation:


Display current branch in bash

To have something like:

 ctroupin@gher13 ~/ULg/DIVA/Diva_python_tools (ReadPlotModule) $

add the following lines to your ~/.bash_profile

 parse_git_branch() {
      git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
 export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "

(but probably also described in the reference book).

Download from

Basic commands


The git reference book is extremely well written so most of the issues one might have can be solved by reading the book.
However it is often easier to type the issue in a google search bar and find the solution in specialized forums.


GitHub is an online project hosting using Git. GHER has now an account on GitHub to store the code and software:
You need to [ create an account in GitHub] in order to be able to contribute to existing codes or to upload yours before the gher-ulg administrator can add you as a member of the organization.


Once that is done, if your code is uploaded in a repository within, the other members of the organization can directly edit the code.


Some repositories are also preserved using zenodo.
This means that every time you create a release (it has to be done through the GitHub webpage, not with the command line), a publication and a DOI will be generated in zenodo (see image below). That release of the code can then be obtained from zenodo and cited properly.


Troubleshooting & FAQ

Move the most recent commits to a new branch

You have performed some changes in the master branch but then decide that these changes should have been inside a new branch:

 git branch newbranch
 git reset --hard hashnumber 
 git checkout newbranch

where hashnumber is the abbreviated commit hash (see Viewing the Commit history).

Modify a file name

 git mv old_name new_name


Changing a remote's URL

You decide that your code should be pushed to another repository or account:
Use the command:

 git remote set-url

Moving files to another repository with history conserved

Well described here:

error: failed to push some refs to

 git fetch origin
 # Fetches updates made to an online repository
 git merge origin YOUR_BRANCH_NAME
 # Merges updates made online with your local work


Moving a code from SVN to Git


Comparison with SVN

Subversion vs. Git: Myths and Facts: list differences between the 2 VCSs.
As the title says, there are some ''myths'' (and ''hype'') about the tools!

Workflow for Diva development

Small fixes

When correcting typos, editing README etc: use the master branch.

Bug fixes

Create specific branch that will be merged, then deleted.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.