Please enter your password of your account at the remote wiki below.
/!\ You should trust both wikis because the password could be read by the particular administrators.

Clear message
Locked History Actions

Projectos/AUGER/MARTA/Tools/GIT

(Under Construction) Instructions for using git

Online git manual available here.

Sequence of commands to run for adding a contribution

  1. git pull --rebase

  2. git commit -am 'Info message about the contribution'

  3. git push

Summary of most important commands

git clone user@lipMachine:~auger/git/repositoryName.git

Clones the shared remote repository to the local directory (do only once)

git log

Info on commits of the local repository

git status

Info on changes in the local repository

git add filename

Stages file for next commit

git commit -m 'Initial project version'

Commit staged changes (with message summarizing them)

git push

Merge local changes (current commit) with remote repository

git pull

Bring and merge remote changes with local repository

git fetch origin

Bring (without merging) remote changes

Tutorial

0. Initialize it

On the server do:

$ git init --bare <directory>

Initialize an empty Git repository, but omit the working directory. Shared repositories should always be created with the --bare flag (see discussion below). Conventionally, repositories initialized with the --bare flag end in .git. For example, the bare version of a repository called my-project should be stored in a directory called my-project.git.

Don't forget to allow for users to write in the git:

$ chmod g+x -R <directory>

This allows the group to write in the directory Recursively

1. User configuration

$ git config --global user.name "Raul Sarmento"
$ git config --global user.email raul _at_ lip.pt

2. Clone remote shared repository to local machine

$ git clone raul@lnlip01.lip.pt:~auger/git/MARTATree.git
Cloning into 'MARTATree'...
Password:
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (12/12), done.
remote: Total 12 (delta 4), reused 0 (delta 0)
Receiving objects: 100% (12/12), 5.61 KiB, done.
Resolving deltas: 100% (4/4), done.

2.1. Go to locally created repository and view commit history

$ cd MARTATree/
$ git log
Commit:  31d8da610511be991944bfed17f88fd5f4bcb5dc
Author:  Auger <bernardo@lip.pt>
Date:    (7 hours ago) 2014-02-05 16:10:58 +0000
Subject: Add flag for dense stations. Removed jump in loop in case of a dense stations. Jump loop if a station does not exhist.


Commit:  8cdfe1e2d12a7138146e86cbd8fd8a4e7328d5f1
Author:  Auger <bernardo@lip.pt>
Date:    (9 hours ago) 2014-02-05 14:18:19 +0000
Subject: Added height (geodetic coordinate) to core and stations position.


Commit:  0036bd68305ce9563e0ab479735cf8e5c7167b3a
Author:  Auger <bernardo@lip.pt>
Date:    (29 hours ago) 2014-02-04 18:18:17 +0000
Subject: Init repository.

$ ll
total 48
drwxr-xr-x   5 raul   170B  5 Fev 23:34 .
drwxr-xr-x   9 raul   306B  5 Fev 23:37 ..
drwxr-xr-x  13 raul   442B  5 Fev 23:34 .git
-rw-r--r--   1 raul    18K  5 Fev 23:34 MARTATree.cc
-rw-r--r--   1 raul   3,2K  5 Fev 23:34 MARTATree.h

3. After editing files locally

3.1. Check status

$ git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   MARTATree.cc
#       modified:   MARTATree.h
#
no changes added to commit (use "git add" and/or "git commit -a")

3.2. Stage files

$ git add MARTATree.*
$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       modified:   MARTATree.cc
#       modified:   MARTATree.h
#

3.3. Commit changes

$ git commit -m 'Fixed shower curvature.'
[master 11aa0bc] Fixed shower curvature.
 2 files changed, 3 insertions(+), 3 deletions(-)

$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)

4. Push your changes to the remote, and check log

$ git push
Password:
Counting objects: 7, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 373 bytes, done.
Total 4 (delta 2), reused 0 (delta 0)
To raul@lnlip01.lip.pt:/home/cosmo/auger/git/MARTATree.git
   31d8da6..11aa0bc  master -> master


$ git log
Commit:  11aa0bc5a534964dab89d6080f09a5be3313a6f3
Author:  Raul Sarmento <raul _at_ lip.pt>
Date:    (65 minutes ago) 2014-02-06 00:01:50 +0000
Subject: Fixed shower curvature.


Commit:  31d8da610511be991944bfed17f88fd5f4bcb5dc
Author:  Auger <bernardo@lip.pt>
Date:    (9 hours ago) 2014-02-05 16:10:58 +0000
Subject: Add flag for dense stations. Removed jump in loop in case of a dense stations. Jump loop if a station does not exhist.


Commit:  8cdfe1e2d12a7138146e86cbd8fd8a4e7328d5f1
Author:  Auger <bernardo@lip.pt>
Date:    (11 hours ago) 2014-02-05 14:18:19 +0000
Subject: Added height (geodetic coordinate) to core and stations position.


Commit:  0036bd68305ce9563e0ab479735cf8e5c7167b3a
Author:  Auger <bernardo@lip.pt>
Date:    (31 hours ago) 2014-02-04 18:18:17 +0000
Subject: Init repository.

5. Bring and merge remote changes (from a different local repository, not yet updated with the commit performed in point 4. above)

$ git pull
remote: Counting objects: 7, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From /home/cosmo/raul/auger_home/git/MARTATree
   31d8da6..11aa0bc  master     -> origin/master
Updating 31d8da6..11aa0bc
Fast-forward
 MARTATree.cc |    4 ++--
 MARTATree.h  |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)