git
appoint

git reflog
git reflog reset
using tilde (~) and caret (^) combined
commit exclusions
^<rev>(caret) notation : To exclude commits reachable from a commit, a prefix^notation is used. E.g.^r1 r2means commits reachable from r2 but exclude the ones reachable from r1 (i.e. r1 and its ancestors)
dotted range notations
..(two-dot) range notationr1..r2: commits that are reachable from r2 excluding those that are reachable from r1 by^r1 r2
...(three-dot) symmetric difference notationr1...r2: called symmetric difference of r1 and r2 It is the set of commits that are reachable from either one of r1 (left side) or r2 (right side) but not from both
commit
get revision number
[!TIP|label:the
<value>can be:]
commit id
branch name
HEAD,HEAD~n,HEAD^^
get abbrev commit ids
[!NOTE|label:references:]
format:
%H: commit hash
%h: abbreviated commit hash
rev-listrev-parse
get previous commit id
get next commit id
[!NOTE] references:
branch
full branch name
branch name
or
create empty branch
create an empty branch
push to remote
git alias
.gitalias:
get branch name from reversion
branch -a --contiansname-rev
get upstream branch
get current
get specific
local
remote
advanced usage
for remote
gitalias
[!NOTE|label:reference:]
check refs
fix warning
get first parent branch
[!NOTE|label:references:]
tag
lightweight VS. annotated
show tags details
show tag type via
git cat-file -t
status
list ignored
[!NOTE|label:references:]
statuscheck-ignorels-filesclean
filter in history
[!NOTE|label:--diff-filter:]
UPPERCASE: include the changes in the diff output
lowercase: exclude the changes in the diff output
A
Added
a newly added file (staged into the Git index)
C
Copied
a file that was recognized as copied from another file
D
Deleted
a file that was deleted
M
Modified
a file that was modified
R
Renamed
a file that was renamed (Git detected a renaming operation)
T
Type changed
a file whose type changed (e.g., from regular file to symlink)
U
Unmerged
a file with unresolved merge conflicts (typically during a merge)
X
Unknown
other unknown types of changes (rare cases)
B
Broken pairing
a previously recognized rename/copy relationship that is now broken (e.g., rename no longer detected)
[!NOTE|label:Git Change Detection Strategy:]
-M[N], --find-renames[=<N>]
detect Renames
Detects renamed files (rename detection) e.g., from a.txt → b.txt.
-C[N], --find-copies[=<N>]
detect Copies
Detects file copies (copy detection) e.g., a.txt → b.txt with similar content.
--find-copies-harder
more aggressive copy detection
Attempts copy detection even for newly added files, not just tracked ones.
-D, --irreversible-delete
irreversible delete
Treats deleted files as untracked i.e., no longer in the index.
--no-renames
disable rename detection
Explicitly disables rename detection (equivalent to default behavior when not enabled).
list all renamed files
[!NOTE|label:references:]
-M[<n>],--find-renames[=<n>]If generating diffs, detect and report renames for each commit. For following files across renames while traversing history, see--follow. If is specified, it is a threshold on the similarity index (i.e. amount of addition/deletions compared to the file’s size). For example,-M90%means Git should consider a delete/add pair to be a rename if more than 90% of the file hasn’t changed. Without a%sign, the number is to be read as a fraction, with a decimal point before it. I.e.,-M5becomes 0.5, and is thus the same as-M50%. Similarly,-M05is the same as-M5%. To limit detection to exact renames, use-M100%. The default similarity index is 50%.
list all deleted files
list files changed by specific users
[!TIP]
see also get diff from particular author
list files changes by pattern

log
short stat
show files and status without comments
more
e.g.:
show submodule changes
get change from .git/objects
.git/objectsget change history for deleted files
or
or
show
show file change details
show file status only
rebase
[!TIP]
about
GIT_SEQUENCE_EDITOR



automatic edit by git rebase -i
git rebase -iinspired from .gitconfig & Is there a way to squash a number of commits non-interactively?

or edit
.gitconfig~/.marslo/bin/arebase.sh
or:
or:
undo
delete only the latest commit
delete multiple commits
revert local
push to remote
revert deleted branches
[!TIP] references:
or find out recent actions
or find all losts
show diff
revert single file to remotes
revert changes in submodule
or
or
git reset
Commit-level
Discard commits in a private branch or throw away uncommited changes
git reset
File-level
Unstage a file
git checkout
Commit-level
Switch between branches or inspect old snapshots
git checkout
File-level
Discard changes in the working directory
git revert
Commit-level
Undo commits in a public branch
git revert
File-level
(N/A)
git resetviagit reflog
git reflog reset git reset --hard
git reset --hard git reset --soft
git reset --hard git revert
git revert
change latest comments in local
change comments in remote
change remote comments
And then change pick to reword
example
change root comments

change author and committer
go to interactive mode
modify
picktoeditamend one by one
[!TIP] see also
-x '-CHEAD'[!TIP]
How to amend several commits in Git to change author
-CHEAD: change the author but maintain the original timestamps
check commits with author
mv
case sensitive
error with regular
git mvrenmae
clean
clean untracked directory and item in .gitignore
.gitignorequick generate .gitignore
using -f twice if you really want to remove such a directory
-f twice if you really want to remove such a directorydiff
diff-highlight
diff-highlight[!NOTE] references:
get diff from particular author
[!TIP]
see also list files changed by specific users
diff ignore whitespace
[!NOTE|label:references:]
ignore tab
[!TIP|label:tab-in-indent]
ignore tab-in-indent for
*.configand*.ltsvonly
ignore all
tag
reference :
discribe
or
get revision in particular branch
get latest tag
references:
or
or
to get verbose output
or
or
or formatted date
or git alias
get revision from latest tag in particular branch
get tags for
HEAD:
example
get tag and distance (depth)
reference:
or --all
[!TIP] prepend "-" to reverse sort order.
ascending :
--sort=<type>descending :
--sort=-<type>references:
via
v:refnameorversion:refnameby created data
checkout
[!NOTE|label:references:]
checkout particular commit and submodules
[!TIP] references:
or
checkout single branch
remote
fetch single branch
[!NOTE|label:references:]
with git remote
with git config
clone --configconfig --add
add more remotes
push to multiple remotes
fetch and push to different repos
blame
blame in line range
-L <start>,<end>-L :<funcname>by keywords (
git log -S)
format
-s-n,--show-number-f,--show-name-e,--show-email[!TIP] This can also be controlled via the blame.showEmail config option.
-l--date[!TIP] check : imarslo: date format setup global in
~/.gitconfig:--color-by-age[!TIP] references:
example:

git blame color by age
tricky
--since
for-each-ref
[!NOTE|label:references:]
--sort:
authordate
committerdate
creatordate
taggerdate
get refs days ago
to archive
delete via
originwill get issueinternal server error
to retrive
format
[!TIP]
foramttinghttps://git-scm.com/docs/git-for-each-ref/2.21.0#Documentation/git-for-each-ref.txt---formatltformatgt
format:
%00->\0(NUL)
%09-> (tab)
%0a-> (LF)field names:
head :
refname:->refs/heads/master
refname:short->master
refname:lstrip=1->heads/master
refname:lstrip=2->master
refname:lstrip=-1->master
refname:lstrip=-2->heads/master
refname:rstrip=1->refs/heads
refname:rstrip=2->refs
refname:rstrip=-1->refs
refname:rstrip=-2->refs/heads
refname:strip=1->heads/master
refname:strip=2->master
refname:strip=-1->master
refname:strip=-2->heads/master
upstream->refs/remotes/origin/master
upstream:short->origin/master
upstream:lstrip=2->origin/master
upstream:lstrip=-2->origin/master
upstream:rstrip=2->refs/remotes
upstream:rstrip=-2->refs/remotes
upstream:strip=2->origin/master
upstream:strip=-2->origin/master
push->refs/remotes/myfork/master
push:short->myfork/master
push:lstrip=1->remotes/myfork/master
push:lstrip=-1->master
push:rstrip=1->refs/remotes/myfork
push:rstrip=-1->refs
push:strip=1->remotes/myfork/master
push:strip=-1->master
objecttype->commit
objectsize->$((131 + hexlen))
objectsize:disk->$disklen
deltabase->$ZERO_OID
parent->''
parent:short->''
parent:short=1->''
parent:short=10->''
numparent->0
object->''
type->''
'*objectname'->''
'*objecttype'->''
author->'A U Thor <author@example.com> 1151968724 +0200'
authorname->'A U Thor'
authoremail->'<author@example.com>'
authoremail:trim->'author@example.com'
authoremail:localpart->'author'
tag->''
tagger->''
taggername->''
taggeremail->''
taggeremail:trim->''
taggeremail:localpart->''
taggerdate->''
subject->'Initial'
subject:sanitize->'Initial'
contents:subject->'Initial'
body->''
contents:body->''
contents:signature->''
contents->'Initial'
HEAD->'*'
objectname->$(git rev-parse refs/heads/master)
objectname:short->$(git rev-parse --short refs/heads/master)
objectname:short=1->$(git rev-parse --short=1 refs/heads/master)
objectname:short=10->$(git rev-parse --short=10 refs/heads/master)
tree->$(git rev-parse refs/heads/master^{tree})
tree:short->$(git rev-parse --short refs/heads/master^{tree})
tree:short=1->$(git rev-parse --short=1 refs/heads/master^{tree})
tree:short=10->$(git rev-parse --short=10 refs/heads/master^{tree})
authordate->'Tue Jul 4 01:18:44 2006 +0200'
committer->'C O Mitter <committer@example.com> 1151968723 +0200'
committername->'C O Mitter'
committeremail->'<committer@example.com>'
committeremail:trim->'committer@example.com'
committeremail:localpart->'committer'
committerdate->'Tue Jul 4 01:18:43 2006 +0200'
objectname:short=1->$(git rev-parse --short=1 refs/heads/master)
objectname:short=10->$(git rev-parse --short=10 refs/heads/master)
creator->'C O Mitter <committer@example.com> 1151968723 +0200'
creatordate->'Tue Jul 4 01:18:43 2006 +0200'tags:
refname->refs/tags/testtag
refname:short->testtag
upstream->''
push->''
objecttype->tag
objectsize->$((114 + hexlen))
objectsize:disk->$disklen
'*objectsize:disk'->$disklen
deltabase->$ZERO_OID
'*deltabase'->$ZERO_OID
tree->''
tree:short->''
tree:short=1->''
tree:short=10->''
parent->''
parent:short->''
parent:short=1->''
parent:short=10->''
numparent->''
type->'commit'
'*objecttype'->'commit'
author->''
authorname->''
authoremail->''
authoremail:trim->''
authoremail:localpart->''
authordate->''
committer->''
committername->''
committeremail->''
committeremail:trim->''
committeremail:localpart->''
committerdate->''
tag->'testtag'
body->''
contents:body->''
contents:signature->''
contents-> `'Tagging at 1151968727``
object->$(git rev-parse refs/tags/testtag^0)
objectname->$(git rev-parse refs/tags/testtag)
objectname:short->$(git rev-parse --short refs/tags/testtag)
'*objectname'->$(git rev-parse refs/tags/testtag^{})
tagger->'C O Mitter <committer@example.com> 1151968725 +0200'
taggername->'C O Mitter'
taggeremail->'<committer@example.com>'
taggeremail:trim->'committer@example.com'
taggeremail:localpart->'committer'
taggerdate->'Tue Jul 4 01:18:45 2006 +0200'
creator->'C O Mitter <committer@example.com> 1151968725 +0200'
creatordate->'Tue Jul 4 01:18:45 2006 +0200'
subject->'Tagging at 1151968727'
subject:sanitize->'Tagging-at-1151968727'
contents:subject->'Tagging at 1151968727'
date format
[!TIP] references:
format:
relative
local
default
iso( oriso8601)
rfc( orrfc2822)
short
raw
format:%Y-%m-%d %I:%M %pstrftime :
%a: Abbreviated weekday name
%A: Full weekday name
%b: Abbreviated month name
%B: Full month name
%c: Date and time representation appropriate for locale
%d: Day of month as decimal number (01 – 31)
%H: Hour in 24-hour format (00 – 23)
%I: Hour in 12-hour format (01 – 12)
%j: Day of year as decimal number (001 – 366)
%m: Month as decimal number (01 – 12)
%M: Minute as decimal number (00 – 59)
%p: Current locale's A.M./P.M. indicator for 12-hour clock
%S: Second as decimal number (00 – 59)
%U: Week of year as decimal number, with Sunday as first day of week (00 – 53)
%w: Weekday as decimal number (0 – 6; Sunday is 0)
%W: Week of year as decimal number, with Monday as first day of week (00 – 53)
%x: Date representation for current locale
%X: Time representation for current locale
%y: Year without century, as decimal number (00 – 99)
%Y: Year with century, as decimal number
%%: Percent sign
%z,%Z: Either the time-zone name or time zone abbreviation, depending on registry settings
how to use
color
[!TIP|label:usage:]
%(color:<color_name>)
%(color:reset)
example
condition
[!TIP|label:references:]
%(if)...%(then)...%(else)...%(end)
%(align:<number>,left) ... %(end)
example
alias
Last updated
