From d68e85bc4307fe3746c33818c85aee829b1962b0 Mon Sep 17 00:00:00 2001 From: johannst Date: Sun, 17 Nov 2019 15:55:42 +0100 Subject: minor formatting --- git.txt | 120 +++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 69 insertions(+), 51 deletions(-) (limited to 'git.txt') diff --git a/git.txt b/git.txt index 9cc7a86..59d1a64 100644 --- a/git.txt +++ b/git.txt @@ -1,67 +1,85 @@ -/* git help */ +# git +------------------------------------------------------------------------------------------------------------------------ - - remote - git remote -v list remotes verbose (with URLs) - git remote show [-n] list info for (like remote HEAD, remote branches, tracking mapping) - -n show available info without contacting remote (offline mode) +# toc + |remote| + |branching| + |resetting| + |tags| + |diff| + |log| + |patching| + |revision_range| - - branching - git branch [-a] list available branches; -a to include remote branches - git branch -vv list branch & annotate with head sha1 & remote tracking branch - git branch create branch with name - git checkout switch to branch with name - git push -u origin push branch to origin (or other remote), and setup as tracking branch + - *remote* + git remote -v ............................... list remotes verbose (with URLs) + git remote show [-n] ............... list info for (like remote HEAD, remote branches, + tracking mapping) - - resetting - git reset [type] - type: - --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 + - *branching* + git branch [-a] ............................. list available branches; -a to include remote branches + git branch -vv .............................. list branch & annotate with head sha1 & remote tracking branch + git branch .......................... create branch with name + git checkout ........................ switch to branch with name + git push -u origin ................. push branch to origin (or other remote), and setup as + tracking branch - - tags - git tag -a -m "descr" creates an annotated tag (full object containing tagger, date, ...) - git tag -l list available tags - git checkout tag/ checkout specific tag - git checkout tag/ -b checkout specific tag in a new branch + - *resetting* + 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 - - diff - 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 + - *tags* + git tag -a -m "descr" ............... creates an annotated tag (full object containing tagger, date, ...) + git tag -l .................................. list available tags + git checkout tag/ .................... checkout specific tag + git checkout tag/ -b ......... checkout specific tag in a new branch - - log - 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 + - *diff* + 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 - - patching + - *log* + 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 + + - *patching* git format-patch / - opt: - -N use [PATCH] even with multiple patches (default is [PATCH n/m] - where n is current commit num and m is total commit num in patch) - --start-number start output file generation with as start number instead '1' - since spcifier: - -3 e.g: create a patch from last three commits - create patch with commits starting after + opt: + -N ...................................... use [PATCH] even with multiple patches (default is [PATCH n/m] + where n is current commit num and m is total commit num in patch) + --start-number ...................... start output file generation with as start number instead '1' + since spcifier: + -3 ...................................... e.g: create a patch from last three commits + ............................ create patch with commits starting after - git am apply patch and create a commit for it + git am .............................. apply patch and create a commit for it - git apply --stat see which files the patch would change - git apply --check see if the patch can be applied cleanly - git apply apply the patch locally without creating a commit + git apply --stat .................... see which files the patch would change + git apply --check ................... see if the patch can be applied cleanly + git apply ........................... apply the patch locally without creating a commit # eg: generate patches for each commit from initial commit on git format-patch -N $(git rev-list --max-parents=0 HEAD) - # generate single patch file from a certain commit/ref - git format-patch --stdout > my-patch.patch + # generate single patch file from a certain commit/ref + git format-patch --stdout > my-patch.patch + + - *revision_range* + HEAD ........................................ last commit + HEAD~1 ...................................... last commit-1 + HEAD~N ...................................... last commit-N (linear backwards when in tree structure, check + difference between HEAD^ and HEAD~) + git rev-list --max-parents=0 HEAD ........... first commit - - - HEAD last commit - HEAD~1 last commit-1 - HEAD~N last commit-N (linear backwards when in tree structure, check difference between HEAD^ and HEAD~) - git rev-list --max-parents=0 HEAD first commit +------------------------------------------------------------------------------------------------------------------------ +vim:sts=2:et:tw=120:cc=120:fo+=t:ft=help: -- cgit v1.2.3