If it is not explicitly told in following recipe, setting up services are described for Ubuntu 16.04 server, but applications are described for Ubuntu 16.04 and/or Lubuntu 16.04 workstation. If you use different Ubuntu version or Linux distribution, settings as well as content, names and places of configuration files may be different!
Got it.

4. Git version control

If necessary, review Version control systems

and notes about practical exercise

Practical exercise

Set user data

  1. Set user data for Git version metadata with commands:

    git config --global user.name "Name Surname"
    git config --global user.email name.surname@example.com
  2. Set default editor for commit notes etc. in git with command, e.g.:

    git config --global core.editor mousepad
  3. Set meld as default merge and diff tool for git:

    git config --global merge.tool meld
    git config --global diff.tool meld

Create Git repository on server

  1. Connect with SSH to the bcserver (get initial password from the teacher):

    ssh uXX@bcserver
  2. Accept server key fingerprint:

    The authenticity of host 'bcserver (<no hostip for proxy command>)' can't be established.
    ECDSA key fingerprint is SHA256:EfeSv9IS82KmbOHismH1JPkqC/j0fxvoe5GK1jR2KVY.
    Are you sure you want to continue connecting (yes/no/[fingerprint])?

    type yes

  3. Enter your initial password for the user:

    uXX@bcserver's password:

    type your password and press Enter

    Don't be confused, that password is not shown as stars/circles/whatever. It is accepted without any visible feedback.

  4. Change password for your user, by entering command on bcserver:

    passwd

    and enter required input:

    Current password:
    New password:
    Retype new password:

    initial password given to you by teacher
    your password
    your password

  5. Create remote Git repository:

    mkdir uXX
    cd uXX
    git --bare init
    exit

    uXX should be replaced with your actual user/project name also in all places below!

Create Git repository in your project

  1. Go to your project:

    cd ~/workspace/uXX
  2. Initialize local Git repository for the project:

    git init
  3. Add remote repository to the project:

    git remote add origin ssh://uXX@bcserver/home/uXX/uXX

    Notice that path to repository has two uXX/uXX (subfolder with the same name as its parent folder).

    or, if you want to change settings, open .git/config file in the project and change settings:

    ...
    [remote "origin"]
    url = ssh://uXX@bcserver/home/uXX/uXX
    ...
  4. Create .gitignore file in your project folder with following content:

    .classpath
    .idea/**
    *.iml
    **/.~lock*
    *.log
    logs/**
    .metadata/**
    .project
    .settings/**
    target/**
    wbp-meta/**

Check configuration

help Run GitTest1 unit test in package jtm.activity031 and check results.

Commit and push changes

All changes can be commited to local repository and pushed to remote repository using following commands1:

cd ~/workspace/uXX
git add -A
git commit -m "Put yor comment here"
git push -u origin master

Update local repository and push changes to remote repository

  1. Use git status to see, what is changed comparing to last commit
  2. Add all changes to your local repository and push them to remote repository:

    cd ~/workspace/uXX
    git pull
    git add -A
    git commit -m "Your message here"
    git push
  3. If you have local git repository with different history than remote project, and know, that local project is OK, then you can forcefully push your project to the server by adding -f switch, e.g.:

    git push -f origin master
  4. To ensure that all your history from local repository is pushed to remote repository, run command:

    git status

    and chek that it returns lines:

    Your branch is up to date with 'origin/master'.

    nothing to commit, working tree clean

Error solutions

Connection timeout

If you have connection timeout:

  1. Open https://www.whatismyip.com/ and check what is public IP address for your computer. Notify teacher (say it and write IP address in Zoom chat).
  2. Wait while teacher will disban your computer from blacklist.

Optional tasks

Use Egit plugin

  1. If your Eclipse doesn't have it already installed, install Egit plugin for Eclipse
  2. Learn How to use Egit plugin
  3. Learn how to use Git branches and merging tools

Clone your project from server

  1. Clone project from server

    cd ~/workspace
    git clone ssh://uXX@bcserver/home/uXX/uXX uXX1

    where uXX is code of your project, and uXX1 is different name of your project.

Use key exchange for SSH connections

If you are tired of writing password for each push, you can enable SSH key exchange by following these instructions:

Additional info

  1. ^ origin is remote repository name, but master is branch mapping (shortened from master:master) from local to remote repository
    -u switch will set master branch of local repository as a default for pushing to remote repository, so after that simple git push and git pull can be used.

  

Created by Valdis Vītoliņš on 2020-05-28 10:48
Last modified by Valdis Vītoliņš on 2021-04-13 14:31
 
Xwiki Powered
Creative Commons Attribution 3.0 Unported License