0% found this document useful (0 votes)
211 views

GITLab Commands

This document provides instructions for using basic GitLab commands for initial setup, editing and adding files, connecting a local repository to a remote repository, cloning a repository, creating and switching branches, pushing local changes to a remote branch, synchronizing a local repository with a remote, and viewing information. Key commands include git config for setup, git add and git commit for editing files, git remote add and git push for connecting local and remote repositories, git clone for cloning, git branch and git checkout for branches, and git fetch and git pull for synchronization.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
211 views

GITLab Commands

This document provides instructions for using basic GitLab commands for initial setup, editing and adding files, connecting a local repository to a remote repository, cloning a repository, creating and switching branches, pushing local changes to a remote branch, synchronizing a local repository with a remote, and viewing information. Key commands include git config for setup, git add and git commit for editing files, git remote add and git push for connecting local and remote repositories, git clone for cloning, git branch and git checkout for branches, and git fetch and git pull for synchronization.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

GITLab Commands

Initial Setup
git config --global user.name pcurtiss
git config --global user.email [email protected]
git config --global push.default matching
git config --global core.editor vim
git config --list

Initial Project Setup


cd <project directory>
git init

Editing and Adding Files


git add <filespec> | . // Adds new files to the local
// repo, or . adds recursively
git commit -a -m 'Text message here' // Commit changes in
//the files to the local repo

Connect local repository to remote repository


// Create remote repo on GITLab server
git remote add origin master <remote url spec (ssh|http)>
git push -u origin master // only need the -u origin master
// when switching/first time

Cloning a repository
git clone <remote url spec (ssh|http)>

Create a branch in local repository


git branch newBranchName

Switch branches in local repository


git checkout <branch> // e.g. git checkout newBranchName

Push local changes into remote new branch


git add .
git commit -a -m 'added important information'
// -a for “add” and –m for “message”
git push -u origin someFiles
// only need the -u origin someFiles when switching

Synchronize your repository with remote


git fetch // sych local repository with remote
// Doesn’t update local branches or create
// local branches to track remote branches
git pull // git fetch followed by git merge to bring
// changes into your working copy
Viewing information
git help commandName // help on a command

git branch –a // list all branches – local & remote

git branch –r // list remote branches

git remote –v // view remotes for push and fetch

You might also like