User Tools

Site Tools


Git Cheat Sheet

Edit your personal data for commits (i.e. name + e-mail address):

EDITOR=<your favourite> git config --global -e
Editor content
# This is Git's per-user configuration file.
        name = <Enter your full real name here>
        email = <Enter your E-Mail here>

Preview1) git pull origin master2):

git fetch origin master ; git diff -R --stat origin/master

Preview3) git pull origin master4), provide full patch forced agains current state in worktree:

git fetch origin master ; git diff -R --diff origin/master -- .

Show committs across branches:

git log --all --stat

Show all commits with some ascii art drawings showing branches and the like:

git log --all --stat --graph

Same, but only for branches, tags and remotes, excluding stash and others:

git log --branches --tags --remotes --stat --graph

Further reading:

Format list of branches to your liking:

git branch --list --format '%(HEAD) %(refname:short)'

will (up to colours) produce the same format as default

Further reading: man git-for-each-ref, Section FIELD NAMES

Reading branch descriptions seems not to be implemented. Branch description seem to be config item and can be read out by

git config --get "branch.<branch name>.description"

Workaround: (local copy)

Branch description can bee created or changed (and thus been seen also) by:

git branch --edit-description <branch name>

Find commits which are in one branch, but not in main:

git log <my branch> ^main

Delete remote branches:

git push [--dry-run] <remote> --delete <old branch>

Reset file to any version from <commitish>:

git checkout <commitish> -- <file>

Show full contents of file <file> from commit, branch or tag <commitish>:

git show <commitish>:<file>

Credits: Using Git Show to View Contents of Files


1) , 3)
provided your working tree is clean
2) , 4)
same as git pull in most cases
docs/tips_n_tricks/git/index.html.txt · Last modified: 24.03.2024 01:30 CET by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki