Here’s a GitLab cheat sheet to help you with common GitLab commands and operations:
Basic GitLab Workflow
Clone a Repository:
git clone <repository_url>
Add Changes:
git add .
Commit Changes:
git commit -m "Your commit message"
Push Changes:
git push origin <branch_name>
Branching
Create a New Branch:
git checkout -b <new_branch_name>
Switch to a Branch:
git checkout <branch_name>
Merge Branch:
git checkout <target_branch>
git merge <source_branch>
Pull Requests
Open a Pull Request:
- Create a new branch with changes and push it.
- Go to the GitLab repository.
- Click on “Merge Requests” and then “New Merge Request.”
- Select the source and target branches.
Fetching and Pulling
Fetch Changes:
git fetch origin
Pull Changes:
git pull origin <branch_name>
Repository Information
Show Remote URLs:
git remote -v
Show Branches:
git branch -a
Tags
List Tags:
git tag -l
Create a Tag:
git tag -a <tag_name> -m "Tag message"
Undoing Changes
Discard Uncommitted Changes:
git restore .
Undo the Last Commit:
git reset --soft HEAD^
GitLab CI/CD
View CI/CD Pipelines:
- Go to your project in GitLab.
- Click on “CI/CD” > “Pipelines.”
View Jobs in a Pipeline:
- Click on a specific pipeline.
GitLab Pages
Set Up GitLab Pages:
- Go to your project in GitLab.
- Click on “Settings” > “Pages” to configure.
GitLab Issues
Create an Issue:
- Go to your project in GitLab.
- Click on “Issues” > “New Issue.”
Reference an Issue in a Commit:
git commit -m "Fixes #issue_number"
This cheat sheet covers some common Git and GitLab commands. Customize it based on your specific project and workflow requirements.