Menu Search Sign up

GIT

Run your own GIT server

https://www.linux.com/learn/how-run-your-own-git-server

GIT Reference

https://git-scm.com/docs

Download and build GIT on Linux

https://mirrors.edge.kernel.org/pub/software/scm/git/

$ tar -zxf git-2.0.0.tar.gz

$ cd git-2.9.5

$ make configure

$ ./configure --prefix=/usr

$ make all doc info

$ sudo make install install-doc install-html install-info

Note: if you do not need Documentation, in above, you can just do:

$ make all

$ sudo make install

Download GIT windows client

https://git-scm.com/download/win

Setting up your git server and client

Let's run through the following scenario: 1) you have a mac client machine 1 which has your java project called "gittest". 2)  you have a windows client machine 2 which you want to have a clone of your java project called "gittest". 3) you have a linux server which you want the 2 clients to push the project and subsequent updates to. Here is what you need to do to set it up.

NOTE: you need to make sure your 3 machines are on the same time clock.

Server settup

$ pwd

/home/myname/git

$ mkdir gittest

$ cd gittest

$ git init --bare

Initialized empty Git repository in /home/myname/git/gittest/

$ ls

branches  config  description  HEAD  hooks  info  objects  refs

$

Mac client machine 1 setup

$ cd gittest

$ git init

$ git add .

$ git commit -m "message" -a

$ git remote add origin ssh://myname@10.69.14.225:/home/myname/git/gittest     

$ git push origin master

The above will push your "gittest" java project from mac client machine 1 to your linux server.

Windows client machine 2 setup

On the windows client machine 2, you only need to clone the project from the server. 

Suppose you already have an existing git project on the server called "gittest" under /home/myname/git/, you can do the following to clone it to your client under ./gittest folder:
$ git clone -v ssh://ec2-user@192.168.1.3:/home/myname/git/gittest gittest

Add, Commit, Push, Pull

From now on, anytime you make any change to your project, do the following:

git add .

git commit -m "my change" -a

git push (or git push origin master)

Anytime you want to pull updates from the server, do the following:

git pull

Common Git Commands

List remote branches

git branch -r

Reference: https://stackoverflow.com/questions/3471827/how-do-i-list-all-remote-branches-in-git-1-7 

 

GIT Client

Overview

GIT client can work with remote Git or SVN repositories.

Download and Install SmartGit

Note: this is a limited-time commercial version.

To download: http://www.syntevo.com/static/smart/download/smartgit/smartgit-portable-17_0_3.7z

To start: .\SmartGit\bin\smartgit64.exe

Clone a remote repository

Repository -> Clone -> Remote Git or SVN repository

Enter the URL for the location of the remote repository

Download and Install SCM GIT

Download the latest version from https://git-scm.com/
Click Git-2.16.1-64-bit.exe to start installation
Follow https://www.tutorialspoint.com/angular2/angular2_environment.htm for choices
By default, git will installed at C:\Program Files\Git 

GIT Lab CICD

Install GIT Runner on Linux

Reference: https://docs.gitlab.com/runner/install/linux-manually.html

First, download one of below:

# Linux x86-64
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64

# Linux x86
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-386

# Linux arm
sudo wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-arm

Second, give it permissions to execute:

sudo chmod +x /usr/local/bin/gitlab-runner

Third, Create a GitLab CI user:

sudo useradd --comment 'GitLab Runner' --create-home gitlab-runner --shell /bin/bash

Fourth, install and run as service:

sudo gitlab-runner install --user=gitlab-runner --working-directory=/home/gitlab-runner

Fifth, start it and check its running status:
sudo gitlab-runner start

sudo /sbin/service gitlab-runner status

You can also check gitlab-runner status by running the following command:

gitlab-runner verify

Runtime platform arch=amd64 os=linux pid=3504 revision=8bb608ff version=11.7.0
Starting multi-runner from /etc/gitlab-runner/config.toml ... builds=0
Running in system-mode.

Configuration loaded builds=0
Listen address not defined, metrics server disabled builds=0
Listen address not defined, session server disabled builds=0

Register GIT Runner with your GitLab project

Reference: https://docs.gitlab.com/runner/register/ 

# gitlab-runner register
Runtime platform arch=amd64 os=linux pid=3067 revision=8bb608ff version=11.7.0
Running in system-mode.

Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
http://10.69.18.251/
Please enter the gitlab-ci token for this runner:
xWDFDcFEFxziTfo2VipS
Please enter the gitlab-ci description for this runner:
[OND4C00562777VM.cihs.ad.gov.on.ca]: MiMMS-PAL-Runner
Please enter the gitlab-ci tags for this runner (comma separated):
mimms-pal-tag
Registering runner... succeeded runner=xWDFDcFE
Please enter the executor: docker+machine, kubernetes, docker-ssh, shell, virtualbox, docker-ssh+machine, docker, parallels, ssh:
shell
Runner registered successfully. Feel free to start it, but if it's running already the config should be automatically reloaded!

You can get the URL and token information from your GitLab project's GitLab project's Settings -> CI/CD -> Runners settings -> Specific Runners -> Setup a specific Runner manually

In your CI/CD .gitlab-ci.yml file, you need to specify the same tag that you provided above:

script:
......
tags:
- mimms-pal-tag

After your registration, you will see runner be displayed in GitLab console for your project.