GitLab CLI Commands

In GITLAB CLI

(From local terminal)

• for create a new branch : - git checkout -b

• for delete an existing branch in local : -git branch -d

• for delete an existing branch in REMOTE : git push origin --delete "branch name"

See Branches

  • View all local branches: git branch
  • View all remote branches: git branch -r
  • View both local and remote branches: git branch -a

Create a Branch

  • Create a new branch but stay on the current branch:
    git branch <branch-name>
  • Create and switch to the new branch:
    git checkout -b <branch-name>
    or (recommended newer version)
    git switch -c <branch-name>

Delete a Branch

  • Delete a local branch: git branch -d <branch-name> (Use -D instead of -d to force delete.)
  • Delete a remote branch: git push origin --delete <branch-name>

Switch Branches

  • Switch to an existing branch: git checkout <branch-name>
    or (recommended newer version)
    git switch <branch-name>

Synchronize Branches

  • Fetch latest changes from remote: git fetch origin
  • Pull latest changes into the current branch:
    git pull origin <branch-name>
  • Push local changes to remote branch:
    git push origin <branch-name>
  • Rebase your branch onto another branch (use with caution): git rebase <branch-name>
  • Merge another branch into the current branch: git merge <branch-name>
Scroll to Top