Skip to content

Instantly share code, notes, and snippets.

@danielrohers
Last active August 29, 2015 14:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielrohers/76dfb52eaf44507b6388 to your computer and use it in GitHub Desktop.
Save danielrohers/76dfb52eaf44507b6388 to your computer and use it in GitHub Desktop.
git commands

Git commands resume

Creating repo

mkdir repo
cd repo
git init
touch README
git add README
git commit -m "first commit"
git remote add origin git@server:path/repo.git
git push -u origin master

Creating

Local: git checkout -b <branch>

Remote:

git checkout -b <branch>

git push origin <branch>

Removing

Local: git branch -d <branch>

Remote: git push origin --delete <branch>

git fetch origin
git diff --name-status master origin/master

Add modified files in the stash: git stash

List stash: git stash list

Add stash files in current branch: git stash apply

Clean stash: git stash clear

Reset HEAD: git reset --hard

Reset commit: git reset --hard <commit hash>

Commit list: git reflog

Checkout file from head: git checkout -- filename

Checkout file from commit: git checkout <commit hash> filename

Ignore: git update-index --assume-unchanged <file>

Start tracking: git update-index --no-assume-unchanged <file>

Docs

Git Documentation

Git Manual Page - Kernel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment