Skip to content

Instantly share code, notes, and snippets.

@DanielHemmati
Created September 8, 2019 21:46
Show Gist options
  • Save DanielHemmati/94a6ca63575a05f357a828f3474d391c to your computer and use it in GitHub Desktop.
Save DanielHemmati/94a6ca63575a05f357a828f3474d391c to your computer and use it in GitHub Desktop.
useful command in git bash command line
git log -p -2
-p => show will show patches (what have been change in the code)
-2 => will show the last two patches (you can put any number)
below is example:
commit 81001544e62a4037b462536f8b041301a5e5db00 (HEAD -> master)
Author: Daniel <--show-origin>
Date: Sun Sep 8 21:45:46 2019 +0200
so i don't know this message is for README or not
but you know i am learning to see how this shit is working
diff --git a/README.md b/README.md
index 46fe255..2d4333f 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,3 @@
so i just modify this dude what now
+i want to write a very large commit massage for beginner
+how about that
commit bae86c55cb30dcaaa956b95f03b20230d47c6f64
Author: Daniel <--show-origin>
Date: Sun Sep 8 21:41:28 2019 +0200
which one goes for commit ?
diff --git a/README.md b/README.md
index 7895941..46fe255 100644
--- a/README.md
+++ b/README.md
@@ -1 +1 @@
-learning git
+so i just modify this dude what now
diff --git a/cont.txt b/cont.txt
new file mode 100644
index 0000000..5d3aade
--- /dev/null
+++ b/cont.txt
@@ -0,0 +1,2 @@
+so what up bro? how is family?
+kljlsf
----------------------------------------------------------------------------
git log --stat
commit ca82a6dff817ec66f44342007202690a93763949
Author: Scott Chacon <schacon@gee-mail.com>
Date: Mon Mar 17 21:52:11 2008 -0700
changed the version number
Rakefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------------
git log --pretty=oneline
ca82a6dff817ec66f44342007202690a93763949 changed the version number
085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 removed unnecessary test
a11bef06a3f659402fe7563abf99ad00de2209e6 first commit
----------------------------------------------------------------------------
go to the page 43 of the git pro, if you ever going to need this
git log --pretty=format:"%h - %an, %ar : %s"
ca82a6d - Scott Chacon, 6 years ago : changed the version number
085bb3b - Scott Chacon, 6 years ago : removed unnecessary test
a11bef0 - Scott Chacon, 6 years ago : first commit
----------------------------------------------------------------------------
i like this --graph it's cool, if you are only working in the command line only
it will be handy
$git log --pretty=format:"%h %s" --graph
* 2d3acf9 ignore errors from SIGCHLD on trap
* 5e3ee11 Merge branch 'master' of git://github.com/dustin/grit
|\
| * 420eac9 Added a method for getting the current branch.
* | 30e367c timeout code and tests
* | 5a09431 add timeout protection to grit
* | e1193f8 support for heads with slashes in them
|/
* d6016bc require time for xmlschema
* 11d191e Merge branch 'defunkt' into local
----------------------------------------------------------------------------
git reset HEAD <file> ==> will unstage the last stage
git restore <file> ==> will restore it to the last version (i mean just test it and you will
figure it out, my english is aweful in this moment) 😂😂
----------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment