Giter Club home page Giter Club logo

gitlab-guideline's Introduction

Git and GitLab Guideline

Table of Contents

  1. Required Tools
  2. Installation
  3. Configuration
    3-1. git config
    3-2. ssh key
    3-3. Gitlab Account
  4. Repository
    5-1. Repository Creation
    5-2. Update Remote
    5-3. Update Local
    5-4. Other Operations
  5. References

Required Tools

Linux

Check if the required packages are existing:

  • Git: $ git --version
  • OpenSSH: $ ssh -V

Windows 10

  • Git for Windows
  • TortoiseGit
    Note that TortoiseGit is different from TortoiseSVN.
    Developers who previously install TortoiseSVN should install TortoiseGit separately.

Installation

Ubuntu

  • Git:
$ sudo apt-get update
$ sudo apt-get install git
  • OpenSSH client:
$ sudo apt install openssh-client

Windows 10

  • Git:

    • Features to be installed
      features

    • Git command-line setup
      env

    • Use OpenSSH is recommended in many tutorial, but it is tested to cause error on Windows 10, so that Tortoise Plink is used instead.
      ssh

    • Tested working
      terminal

    • Recommanded
      line-ending

    • Left as default
      extra

  • TortoiseGit:

    • Register for git
      tortoisegit-setup-features

    • Unlike showing in the picture, choose TortoiseGitPLink, which is better for Windows:
      tortoisegit-ssh-client

Configuration

git config

For Linux, use those commands on terminal;
For Windows, those can be applied on Git Bash:

$ git config --global user.name "Your Name"
$ git config --global user.email "[email protected]"

The config info is stored in $HOME/.gitconfig:

[user]
	email = [email protected]
	name = username

The location of $HOME/.gitconfig:

  • For Linux: ~/.giconfig or /home/your-username/.gitconfig
  • For Windows: C:/Users/Your-Username/.gitconfig

ssh key

For Linux and Git Bash on Windows:

Generating the key:

$ ssh-keygen -t rsa -C "a-title-your-can-remember"

The default location to save the ssh key: $HOME/.ssh/id_rsa

Catching the key:

$ cat ~/.ssh/id_rsa.pub

To add:

$ ssh-add ~/.ssh/id_rsa

For Windows user, since TortoiseGit is being used, there is a different way to add ssh key:

  1. From [start] menu, run [PuTTYgen]:

  2. If you have not generated a key using Git Bash, you can [generate] it now:
    puttygen

  3. If you already have a key, you can now [load] the key (default path: $HOME/.ssh/id_rsa)

  4. Click [Save private key], save it as .ppk file:

  5. In your project repository, right click and navigate to [TortoiseGit] => [Settings]

  6. Navigate to [Git] => [Remote], choose a name from [Remote]. for the field Putty Key, browse the folder of your ssh keys, and open the .ppk file your want:
    tortoisegit-add-ppk

GitLab Account
  1. Catch the ssh key on terminal or Git Bash and copy, or copy it from PuTTYgen:
    $ cat ~/.ssh/id_rsa.pub
    ssh-cat

  2. Login to your GitLab account, navigate to [Profile Settings], go to [SSH Keys] tab, past to [key] area; if the format is correct, the [Title] should be automatically generated:
    gitlab-add-key

Repository

remote: ssh and https
gitlab-remote

branch: master

Creat Repository

Clone: $ git clone [url] (directory)
Init:

$ git init
$ git remote add origin [url]

Update Repository

$ git status    # check changes
$ git add [file(s) separated by whitespace] # add file to commit
$ git commit -m "message"   # save the changes locally
$ git pull (origin) (master)    # update from remote
$ git checkout -b [branch-name] # for developers and lower
$ git push (origin) (master)    # update from local

Other Operations

Resolve conflicts: manually
$ git diff # find the conflicts

Remote modification:

$ git remote rename [old-remote] [new-remote]    # renaming
$ git remote remove [remote-name]    #remove

Protected branch:
Push directly: Master and higher
Push to a new branch and send merge request: Developer and lower

References

Git and TortoiseGit: Step by Step

Tutorial in Chinese: liaoxuefeng

gitlab-guideline's People

Contributors

hanabinoir avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.