User Tools

Site Tools


docs:tips_n_tricks:git:index.html

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
docs:tips_n_tricks:git:index.html [12.05.2023 11:31 CEST] – removed - external edit (Unknown date) 127.0.0.1docs:tips_n_tricks:git:index.html [24.03.2024 01:30 CET] (current) peter
Line 1: Line 1:
 +====== Git Cheat Sheet ======
  
 +----
 +
 +Edit your personal data for commits (i.e. name + e-mail address):
 +  EDITOR=<your favourite> git config --global -e
 +
 +<code properties Editor content>
 +# This is Git's per-user configuration file.
 +[user]  
 +        name = <Enter your full real name here>
 +        email = <Enter your E-Mail here>
 +</code>
 +----
 +
 +Preview((provided your working tree is clean)) ''git pull origin master''((same as ''git pull'' in most cases)):
 +
 +  git fetch origin master ; git diff -R --stat origin/master
 +
 +----
 +
 +Preview((provided your working tree is clean)) ''git pull origin master''((same as ''git pull'' in most cases)), 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:__  https://stackoverflow.com/questions/1838873/visualizing-branch-topology-in-git/34467298#34467298 
 +
 +----
 +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"
 +
 +__Reference__: https://stackoverflow.com/questions/15058844/print-branch-description\\ 
 +__Workaround__: https://glebbahmutov.com/blog/git-branches-with-descriptions/ ([[docs:tips_n_tricks:git:branches.sh|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__: [[https://www.serverlab.ca/scripting-programming/using-git-show-to-view-contents-of-files/|Using Git Show to View Contents of Files]]
 +----
 +
 +{{entry>git}}{{tag>git}}

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki