Skip to content

dschetel/GitCheatSheet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git Cheat Sheet

Git Cheat sheet in all its glory..!

Download Cheat sheet

Table of contents

Scenarios

Some scenarios with a bit more explicit commands

Create a repo

From existing project

cd ~/projects/myproject
git init
touch .gitignore
> use http://www.gitignore.io
git add .gitignore
git commit -m 'added gitignore'
git add .
git commit -m 'initial commit'

From existing repo

git clone ~/existing/repo
git clone http://remoteRepository/project.git

Branching

Merge branch B1 into branch B2

git checkout B2
git merge B1

How to resolve merge conflicts

  • Start merge (git merge)
  • Use editor to search for merge conflict (HEAD)
  • Resolve conflicts
  • git commit

Log

git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
git lg

Diff

Diff word-by-word

git diff --word-diff

See all staged changes done to a local repo

git diff --cached

List every changed file between two commits

git diff --name-only <commit-hash> <commit-hash>

How to get private repos

  1. Register at gitub using your @uke.de email
  2. Go to https://education.github.com/discount_requests/new
  3. Apply for a student pack

About

Cheat sheet for Git in all its glory

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages