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
Command Description 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 pull
Pull changes from a remote repository git status
Check the status of your local repository git log
View commit history
Repositories
Command Description git init
Initialize 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 pull
Pull changes from a remote repository git branch
List 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 -v
List all remote repositories git remote set-url origin <new-repository>
Change the URL of a remote repository
Branches
Command Description git branch
List 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
Command Description git add <file>
Add a file to the staging area git commit -m ""<message>""
Commit changes with a message git commit --amend
Amend the last commit git reset <file>
Unstage a file git reset --hard
Discard all changes git diff
Show changes between commits git blame <file>
Show who made changes to a file
Merge Requests
Command Description 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 stash
Stash changes git stash apply
Apply stashed changes git stash drop
Delete stashed changes
Issues
Command Description 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 list
List all issues git issue show <issue-number>
Show details of an issue git issue create
Create 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
Command Description git wiki list
List 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
Command Description .gitlab-ci.yml
Configuration file for CI/CD gitlab-runner register
Register a runner gitlab-runner run
Run a runner gitlab-runner exec
Execute a job locally gitlab-runner verify
Verify the configuration of a runner gitlab-runner list
List all runners gitlab-runner uninstall
Uninstall a runner
Groups
Command Description git group list
List 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
Command Description git user list
List 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
Command Description 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 true
Enable colored output git config --global alias.<alias-name> ""<command>""
Create an alias for a command
Reference:
https://docs.gitlab.com/