From d646cf94c0cbe74baef5e5711a3cd3f53afc096d Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Sun, 3 Oct 2021 14:03:49 +0200 Subject: git: re-structure + new notes --- src/tools/git.md | 74 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 44 insertions(+), 30 deletions(-) (limited to 'src/tools') diff --git a/src/tools/git.md b/src/tools/git.md index a4af0cf..a626eae 100644 --- a/src/tools/git.md +++ b/src/tools/git.md @@ -18,25 +18,18 @@ remote branches git branch -vv ................. list branch & annotate with head sha1 & remote tracking branch - git branch ............. create branch with name + git branch ............. create local branch with name + git branch -d .......... delete local branch with name git checkout ........... switch to branch with name git checkout --track .. start to locally track a remote branch - git push -u origin .... push branch to origin (or other remote), and - setup as tracking branch -``` -## Resetting -```markdown - git reset [opt] - opt: - --mixed .................... resets index, but not working tree - --hard ..................... matches the working tree and index to that - of the tree being switched to any changes to - tracked files in the working tree since - are lost - git reset HEAD .......... remove file from staging - git reset --soft HEAD~1 ........ delete most recent commit but keep work - git reset --hard HEAD~1 ........ delete most recent commit and delete work + # Remote + + git push -u origin ........ push local branch to origin (or other + remote), and setup as tracking + branch + git push origin --delete .. delete branch from origin (or + other remote) ``` ## Tags @@ -46,29 +39,36 @@ git tag -l ........................... list available tags git checkout tag/ ............. checkout specific tag git checkout tag/ -b .. checkout specific tag in a new branch -``` -## Diff -```markdown - git diff HEAD: origin/HEAD: ... diff files for different refs - git diff -U$(wc -l ) ......... shows complete file with diffs - instead of usual diff snippets -``` + # Remote -## Log -```markdown - git log --oneline .... shows log in single line per commit -> alias for - '--pretty=oneline --abbrev-commit' - git log --graph ...... text based graph of commit history - git log --decorate ... decorate log with REFs + git push origin --tags .... push local tags to origin (or other remote) ``` -## File history +## Log & Commit History ```markdown + git log --oneline ......... shows log in single line per commit -> alias for + '--pretty=oneline --abbrev-commit' + git log --graph ........... text based graph of commit history + git log --decorate ........ decorate log with REFs + git log -p ......... show commit history + diffs for git log --oneline .. show commit history for in compact format ``` +## Diff & Commit Info +```markdown + git diff .. [] .... show changes between two arbitrary + commits. If one is omitted + it is if HEAD is specified. + git diff -U$(wc -l ) ....... shows complete file with diffs + instead of usual diff snippets + git diff --staged ....................... show diffs of staged files + + git show --stat ................ show files changed by + git show [] .............. show diffs for +``` + ## Patching ```markdown git format-patch / @@ -95,6 +95,20 @@ git format-patch --stdout > my-patch.patch ``` +## Resetting +```markdown + git reset [opt] + opt: + --mixed .................... resets index, but not working tree + --hard ..................... matches the working tree and index to that + of the tree being switched to any changes to + tracked files in the working tree since + are lost + git reset HEAD .......... remove file from staging + git reset --soft HEAD~1 ........ delete most recent commit but keep work + git reset --hard HEAD~1 ........ delete most recent commit and delete work +``` + ## Submodules ```markdown git submodule add [] .......... add new submodule to current project -- cgit v1.2.3