Actions

EmSys

Getting Started with GITLAB

From EdWiki

1. Install Git

The easiest way to install Git on Linux is, using the preferred package manager of your Linux distribution

  • Fedora
yum install git-core
  • Debian/Ubuntu
sudo apt-get install git-core

2. First-Time Git Setup

The first thing you should do when you install Git is to set your username and e-mail address. This is important because every Git commit uses this information, and it's immmutably baked into the commits you pass around.

git config --global user.name "Full User Name"
git config --global user.email "usrname@dese.iisc.ernet.in"
  • Checking your Settings
git config --list
  • Getting Help
git help <verb>
git <verb> --help
man git-<verb>
git help config    # manpage help for the config command
  • Ignoring Files

Often, we have a class of files that we don't want Git to automatically add or even show us being untracked. These are generally automatically generated files such as files produced by the build system. In such cases, create a file named .gitignore listing patterns to match them.

FileĀ : .gitignore
# Comment - this is ignored
*.o        # no .o files
*.obj      # no .obj files
*.a        # no .a files
!*lib.a    # but do track lib.a, even though we are ignoring .a files

Setting up .gitignore file before you get going is generally a good idea so yo don't accidentally commit files that you really don't want in your Git repository.

3. Generating SSH key

To generate a new SSH key just open your terminal and type the following command

ssh-keygen -t rsa -C "usrname@dese.iisc.ernet.in"  # Creates a new ssh key using the provided email

4. Logon to GITLAB Server

GITLAB Login

GITLAB is available on IP Address - 10.114.15.15. In the Web-Browser Address bar type:

http:://10.114.15.15

Provide User Name and Password as:

USER Name = DESE domain e-mail address  # usrname@dese.iisc.ernet.in
Password  = DESE domain password

and click on the LDAP Sign in Button

5. Add SSH key to GitLab SSH Keys

This is necessary to work on your computer (laptop/workstation) and do the push, pull, etc to git Server(GITLAB). SSH key allows you to establish a secure connection between your computer and GITLAB.

My Profile

Once you have logged in successfully, Select My Profile from the Dashboard as shown in the Fig.





Profile


A User Profile Window is presented, In this window, Click on Add Public Key Button.

GITLAB add SSH Keys










Next, copy the contents of ~/.ssh/id_rsa.pub (public key) and paste it in the Key text box. Now Click on the Save button as shown in Fig.







6. Create Project on the git Server

It is necessary to create a project of the same name on the GITLAB before you do any push, pull operation from your computer.

GITLAB Create Project

If You have not logged on to GITLAB (10.114.15.15), logon to it using DESE domain e-mail and password using LDAP Sign In. In the Dashboard click on the Projects. In the Project Window, Click on the + New Project button as shown in the Fig.

GITLAB New Project






In the New Project Window, type the Project Name and click on the Create Project button.






7. Create Project On your computer

Now, On your laptop/workstation, create a project (folder) of the same name what you have created on the GITLAB, and track it using git(GITLAB).

mkdir simple 
cd simple 
git init 
touch README 
git add README 
git commit -m 'first commit' 
git remote add origin git@10.114.15.15:usrname/simple.git 
git push -u origin master

8. Existing Project?

Create a project of the same name as existing project on the GITLAB as explained in step 6. Then

cd existing_project
git init
git add .
git remote add origin git@10.114.15.15:username/existing_project.git 
git push -u origin master

See Also

  1. GIT Basic Commands
  2. Working with Remote Repositories