command branding logo

Git

Git is software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development.

Git Commands List

Command Name
Command
Command Description
Initialize Git
git init
Initialize a local Git repository
git clone
cd ../
Create a local copy of a remote repository
Git Status
git status
Check current git status
Add File For Staging
git add FileName.txt
Adds Single File For Staging
Add All Files For Staging
git add .
Stage All Changed Files
Commit Staged Files
git commit -m "[commit message]"
Commits the current staged files
Commit Staged Files
git commit -m "[commit message]"
Commits the current staged files
List Branches
git branch
List branches (the asterisk denotes the current branch)
Create New Branch
git branch [branch name]
Create a new branch
Delete Branch
git branch -d [branch name]
Delete a branch
Delete Remote Branch
git push origin --delete [branchName]
Delete a remote branch
Create and Change To New branch
git checkout -b [branch name]
Create a new branch and switch to it
Clone And Switch To Remote Branch
git checkout -b [branch name] origin/[branch name]
Clone a remote branch and switch to it
Switch To branch
git checkout [branch name]
Switch to a branch by Name
Merge Branch Into Current Branch
git merge [branch name]
Merge a branch into the active branch
Merge Branch Selected Branches
git merge [source branch] [target branch]
Merge a branch into a target branch
Stash All Current Changes
git stash
Delete changes in current branch back to last commit
Reset Head To Last Commit
git reset --soft HEAD~1
Reset head to last commit
Reset Head To Two Commits Back
git reset --soft HEAD~2
Reset head to two commits back
List Git Configurations
git config --list
lists the git config file for current repo
List Global Git Configurations
git config --global --list
Lists the git config file for global current repo Settings
Push Current Branch Staged Files
git push
Push changes to remote repository (remembered branch)
Push Branch To Remote Repo
git push origin [branch name]
Push a branch to your remote repository
Push Branch To Remote Repo
git push -u origin [branch name]
Push changes to remote repository (and remember the branch)
Delete Remote Branch
git push origin --delete [branch name]
Delete a remote branch
Update Local Repo
git pull
Update local repository to the newest commit
Update Local Repo By Branch Name
git pull origin [branch name]
Update local repository to the newest commit from remote branch
Fetch remote origin without merge
git fetch origin
Gets remote origins most up to date commits without merging
rebases the current branch on the latest origin main
git rebase origin/main
takes the current branch and changes the break off point at the latest origin main
Continue Git rebase
git rebase --continue
when in the middle of a rebase. this finishes off the rebase and confirms it.
Push Rebase To Remote
git push --force-with-lease origin HEAD
This Force pushes rebase to remote location without overwritting any work on that branch. will prevent if there is a commit in the way
Abort Rebase
git rebase --abort
This aborts the rebase process and returns the branch to its original state
Add Remote Repo To Local Project
git remote add origin ssh://git@github.com/[username]/[repository-name].git
Add a remote repository to local project
View Changes
git log
View changes
View Changes
git log --summary
View changes (detailed)