git log -p <#of-commits> => prints verbosely(code-diff)

git log --graph ascii graph of branches

git log --stat [++–]

git log --since=2.weeks time

git log --author (or –commiter for commiter)

git commit --amend to revert the latest commit

git commit -m 'initial commit'
git add forgotten_file
git commit --amend

will discard the latest commit add a new file to the commit and recommit with the added file

git reset HEAD <FILE> to unstage file

git reset HEAD~<#> goes # commits back.

git rebase -i HEAD~<#> allows you to change commit messages of # numbers of commits interactively

git checkout -- <file> to revert the changes and restore origin (e.g. version after clone)

git remote add <shortname> <url> adds remote repository

git remote -v displays all remote repos with urls

git fetch <remote branch (or shortname)> get changes from remote

git fetch origin gets news from origin==remote tree

git remote show origin check tracked branches

git remote rename <odl> <new> change name

git remote rm paul del remote

git brach <branchname> only creates branch but does not switch to it HEAD still points on master

git checkout <branchname> switch to newly created branch HEAD now points on

git checkout -b '<branchname>' short for branch => checkout

git merge <branchname> will result in a merge-commit it it has more than 1 ancestor, which creates a seperate(new) commit

if mergeconflict occures change files to resolve the diff and git add to stage the changes git commit finishes the merge

git branch --merged (--no-merged) will display the respective status of the branch

git push <remote> <branch> will upload to repository

git merge <remote>/<branch> to merge this branch with your current working tree

git checkout -b <branch> <remote>/<branch> will create a own branch with the changes for you to work on

** will be a Tracking-Branch (git pull will automatically get changes from remote (git push accordingly) --track for manual use) **

** git push <remote> :branchname CAUTION! this will delete the remote branch**


git checkout <branch_to_be_rebased>
git rebase <master>
git checkout <master>
git merge <branch_to_be_rebased>

go to the branch you wanted to rebase, rebase master to make your tree linear again, finally go to your master branch and merge the changes.

git rebase --onto master server client advanced stuff.. later plx

git clean -fd cleans working directory to be able to rebase

git stash -u stashes everything including -u(untracked files)

git stash list lists all available stashes

git pull --rebase <remote> <branch> rebase of local branch with remote/branch

git pull <remote> <branch> pulls changes from

git merge --no-commit --squash <branchname> no commmit, no merge-commit

git stash stashes uncommited changes

git stash drop <stash@<id>> drops from stashlist

git stash pop applys last stashed item and removes it from list

git stash apply applys last stashed item without removing it

git config --global alias.stash-unapply '!git stash show -p | git apply -R' cool feature for unapplying appied stashes

git config --global commit.template $HOME/.gitmessage.txt standard commit message


Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>