GITLab Commands
Initial Setup
git config --global user.name pcurtiss
git config --global user.email pcurtiss@mtech.edu
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