GIT

Aus Peter Fuerholz' Wiki
Zur Navigation springen Zur Suche springen

Since OpenShift Express uses GIT as "file transfer" mechanism GIT is a requirement to be installed on the development computer.

Installation

See [1] Go on like this:

  1. Install gitcore and gitosis
  2. Initialize gitosis (The SSH-file has been already created for the OpenShift setup.):
    pfu@latitude:~$ sudo -H -u gitosis gitosis-init < ~/.ssh/id_rsa.pub
    [sudo] password for pfu:
    Initialized empty Git repository in /srv/gitosis/repositories/gitosis-admin.git/
    Reinitialized existing Git repository in /srv/gitosis/repositories/gitosis-admin.git/
    pfu@latitude:~$
  3. Clone a repository (The user 'gitosis' has been created on gitosis installation):
    pfu@latitude:~$ git clone gitosis@latitude:gitosis-admin.git
    Initialized empty Git repository in /home/pfu/gitosis-admin/.git/
    The authenticity of host 'latitude (192.168.178.37)' can't be established.
    RSA key fingerprint is XX:XX:XX......
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added 'latitude,192.168.178.37' (RSA) to the list of known hosts.
    remote: Counting objects: 5, done.
    remote: Compressing objects: 100% (4/4), done.
    remote: Total 5 (delta 0), reused 5 (delta 0)
    Receiving objects: 100% (5/5), done.
    pfu@latitude:~$
    --> /srv/gitosis/repositories/gitosis-admin.git got copied (cloned) to my home (~)
  4. Go to cloned repository and add a project:
    1. cd ~/gitosis-admin
    2. gedit gitosis.conf and add 'group team'-section:
      [gitosis]
      [group team]
      writable = testproject
      members = pfu@latitude
      [group gitosis-admin]
      writable = gitosis-admin
      members = pfu@latitude
    3. save, leave gedit, commit und push:
      pfu@latitude:~/gitosis-admin$ git commit -a -m "Added 'testproject"
      [master cd72fb2] Added 'testproject'
      Committer: Peter Fürholz <pfu@latitude.fritz.box>
      Your name and email address were configured automatically based
      on your username and hostname. Please check that they are accurate.
      You can suppress this message by setting them explicitly:
      git config --global user.name "Your Name"
      git config --global user.email you@example.com
      If the identity used for this commit is wrong, you can fix it with:
      git commit --amend --author='Your Name <you@example.com>'
      1 files changed, 4 insertions(+), 0 deletions(-)
      pfu@latitude:~/gitosis-admin$ git push
      Counting objects: 5, done.
      Delta compression using up to 4 threads.
      Compressing objects: 100% (3/3), done.
      Writing objects: 100% (3/3), 381 bytes, done.
      Total 3 (delta 0), reused 0 (delta 0)
      To gitosis@latitude:gitosis-admin.git
      XXXX..XXXX master -> master
      pfu@latitude:~/gitosis-admin$
      -> /srv/gitosis/repositories/gitosis-admin.git is now updated!
  5. Create the newly added project:
    1. pfu@latitude:~$ mkdir testproject
      pfu@latitude:~$ cd testproject/
      pfu@latitude:~/testproject$ git init
      Initialized empty Git repository in /home/pfu/testproject/.git/
      pfu@latitude:~/testproject$ touch test1.txt
      pfu@latitude:~/testproject$ touch test2.txt
      pfu@latitude:~/testproject$ git add .
      pfu@latitude:~/testproject$ git commit -a -m "Initial import"
      [master (root-commit) 14cfef9] Initial import
      Committer: Peter Fürholz <pfu@latitude.fritz.box>
      Your name and email address were configured automatically based
      on your username and hostname. Please check that they are accurate.
      You can suppress this message by setting them explicitly:
      git config --global user.name "Your Name"
      git config --global user.email you@example.com
      If the identity used for this commit is wrong, you can fix it with:
      git commit --amend --author='Your Name <you@example.com>'
      0 files changed, 0 insertions(+), 0 deletions(-)
      create mode 100644 test1.txt
      create mode 100644 test2.txt
      pfu@latitude:~/testproject$ git remote add origin gitosis@latitude:testproject.git
      pfu@latitude:~/testproject$ git push origin master
      Initialized empty Git repository in /srv/gitosis/repositories/testproject.git/
      Counting objects: 3, done.
      Delta compression using up to 4 threads.
      Compressing objects: 100% (2/2), done.
      Writing objects: 100% (3/3), 234 bytes, done.
      Total 3 (delta 0), reused 0 (delta 0)
      To gitosis@latitude:testproject.git
      * [new branch] master -> master
      pfu@latitude:~/testproject$
      --> /srv/gitosis/repositories/testproject.git got now created!

Usage

Checking in last changes

Customized to my settings:

 cd /workspace/git/FwApps
 git status
 git add .  (Adds everything that is new and is not filtered out by .gitignore. More exactly, it stages untracked files and folder.)
 git commit -a -m "<comments>] (otherwise nano editor appears to enter text)
 git push assembla

Instead of git commit -a you can add and remove files manually by means of git add / git rm

Then check status on Assembla.

If you forget something to check in:

 git commit --amend -m "<comments>"

Problems

I once had the problem that 'master' was not on the latest changes. Thus, git push didn't push the latest changes. See here and here to solve that strange problem. How I ran into this problem was unable to reproduce (don't know really). I did something like this (see links above):

 git log -1
 git checkout master
 git reset --hard 2370a6c3e2a8b300532277321ddc8d128565092e  (value shown on git log -1)