Skip to content

Files

Latest commit

author
Cormac O'Mahony
Sep 28, 2017
d0a0bc8 · Sep 28, 2017

History

History
55 lines (37 loc) · 1.13 KB

Git Commands.md

File metadata and controls

55 lines (37 loc) · 1.13 KB

Git Commands

Remove all your local git branches but keep master

git branch | grep -v "master" | xargs git branch -D

Create a new branch BASED ON THE CURRENT BRANCH

git checkout -b

Undo all local pending changes

git reset HEAD --hard

Undo a single file change

git checkout --

Push new branch to server

git push origin

Delete remote branch

git push origin --delete

List all local and remote branches

git branch -a

Remove deleted branches

git remote prune origin

Pull remote master branch and merge it into current branch

git pull origin master

Undo last commit but keep files (before it's pushed)

git reset HEAD~1

Rename current branch to new name

git branch -m

Save temporarily your changes so you can check out another branch

git stash

List temporary saves

git stash list

Get back changes from a temporary save

git stash apply

Delete temporary saves

git stash drop

Rename local branch

git branch -m

Amend Your Last Commit

git commit --amend

See Changed Files Between Branches

git diff --name-only