GitLab Cheat Sheet

In Git, Gitlab

GitLab is a web-based Git repository manager that provides a complete DevOps platform for software development teams. It is an open-source platform that allows developers to collaborate on code, manage projects, and automate the software development process. GitLab offers a wide range of features, including version control, issue tracking, continuous integration and deployment, code review, and more.

One of the key benefits of GitLab is its ability to provide a single platform for all aspects of the software development process. This means that developers can manage their code, track issues, and deploy their applications all from one place. GitLab also offers a powerful set of collaboration tools, including merge requests, code reviews, and comments, which make it easy for teams to work together on projects.

This cheat sheet provides a quick reference guide for Git/GitLab commands and features.

Table of Contents

Getting Started

CommandDescription
git clone <repository>Clone a repository to your local machine
git remote add origin <repository>Add a remote repository
git push -u origin <branch>Push changes to a branch
git pullPull changes from a remote repository
git statusCheck the status of your local repository
git logView commit history

Repositories

CommandDescription
git initInitialize a new repository
git remote add origin <repository>Add a remote repository
git clone <repository>Clone a repository to your local machine
git push -u origin <branch>Push changes to a branch
git pullPull changes from a remote repository
git branchList all branches
git branch <branch>Create a new branch
git checkout <branch>Switch to a different branch
git merge <branch>Merge a branch into the current branch
git remote -vList all remote repositories
git remote set-url origin <new-repository>Change the URL of a remote repository

Branches

CommandDescription
git branchList all branches
git branch <branch>Create a new branch
git checkout <branch>Switch to a different branch
git merge <branch>Merge a branch into the current branch
git branch -d <branch>Delete a branch
git branch -m <old-branch> <new-branch>Rename a branch

Commits

CommandDescription
git add <file>Add a file to the staging area
git commit -m ""<message>""Commit changes with a message
git commit --amendAmend the last commit
git reset <file>Unstage a file
git reset --hardDiscard all changes
git diffShow changes between commits
git blame <file>Show who made changes to a file

Merge Requests

CommandDescription
git merge <branch>Merge a branch into the current branch
git merge --no-ff <branch>Merge a branch with a new commit
git cherry-pick <commit>Apply a commit to the current branch
git rebase <branch>Rebase the current branch onto another branch
git rebase -i <commit>Interactive rebase
git stashStash changes
git stash applyApply stashed changes
git stash dropDelete stashed changes

Issues

CommandDescription
git commit -m ""Fixes #<issue-number>""Link a commit to an issue
git commit -m ""Closes #<issue-number>""Close an issue with a commit
git commit -m ""Refs #<issue-number>""Reference an issue with a commit
git issue listList all issues
git issue show <issue-number>Show details of an issue
git issue createCreate a new issue
git issue edit <issue-number>Edit an issue
git issue close <issue-number>Close an issue
git issue reopen <issue-number>Reopen a closed issue

Wiki

CommandDescription
git wiki listList all wiki pages
git wiki show <page>Show the contents of a wiki page
git wiki create <page>Create a new wiki page
git wiki edit <page>Edit a wiki page
git wiki delete <page>Delete a wiki page

CI/CD

CommandDescription
.gitlab-ci.ymlConfiguration file for CI/CD
gitlab-runner registerRegister a runner
gitlab-runner runRun a runner
gitlab-runner execExecute a job locally
gitlab-runner verifyVerify the configuration of a runner
gitlab-runner listList all runners
gitlab-runner uninstallUninstall a runner

Groups

CommandDescription
git group listList all groups
git group show <group>Show details of a group
git group create <group>Create a new group
git group edit <group>Edit a group
git group delete <group>Delete a group

Users

CommandDescription
git user listList all users
git user show <user>Show details of a user
git user create <user>Create a new user
git user edit <user>Edit a user
git user delete <user>Delete a user

Settings

CommandDescription
git config --global user.name ""<name>""Set your name
git config --global user.email ""<email>""Set your email
git config --global core.editor ""<editor>""Set your default editor
git config --global color.ui trueEnable colored output
git config --global alias.<alias-name> ""<command>""Create an alias for a command

Reference:

https://docs.gitlab.com/