Reset
Reset soft means reset last commit, modifications remain in staging
#!/bin/sh
: "Commit reset
Reset soft / modifications remain in staging
Reset / modifications are removed from staging
Reset hard / modifications are removed, but stored in gargage
You can get the commit back as long as it was within a few days
"
alias gs="git status | sed 's/^/\t/'"
alias gsp="git status --porcelain | sed 's/^/\t/'; echo"
alias tab2lines="sed 's/^/\t/'; echo"
touch a.txt
echo "touch"; gsp
git add .
echo "git add"; gsp
echo "git commit"
git commit -am 'My commit' | tab2lines
echo "git last log"
git log -n 1 --oneline | tab2lines
git reset --soft HEAD~1
echo "Reset soft ~1"; gsp
git commit -aqm 'm'
echo "git commit"; gs
git reset HEAD~1 | tab2lines
echo "Reset ~1"; gsp
git add .
git commit -qm 'm'
echo "git commit"; gs
git rm -f a.txt > /dev/null
touch
?? main/basics/reset/a.txt
git add
A main/basics/reset/a.txt
git commit
[main a310a57] My commit
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 main/basics/reset/a.txt
git last log
a310a57 My commit
Reset soft ~1
A main/basics/reset/a.txt
git commit
On branch main
nothing to commit, working tree clean
Reset ~1
?? main/basics/reset/a.txt
git commit
On branch main
nothing to commit, working tree clean
Diff
Difference beetwen file modifications and last commits
#!/bin/sh
: "git diff
Differences beetwen file modficiations and its commits
HEAD / refers to current commit
HEAD^ / refers to the commit before the current commit
"
alias gs="git status | sed 's/^/\t/'; echo"
alias gsp="git status --porcelain | sed 's/^/\t/'; echo"
alias tab2lines="sed 's/^/\t/'; echo"
echo "A" > myfile.tmp
echo "write A"; gsp
git add .
git commit -qm 'm'
echo "git commit"; gs
echo "B" > myfile.tmp
echo "overwrite"; gsp
echo "C" >> myfile.tmp
echo "write"; gsp
echo "git diff"
git diff HEAD myfile.tmp | tab2lines
git add .
git commit -qm 'm'
echo "git commit"; gs
git rm -f myfile.tmp > /dev/null
write A
?? main/basics/reset/myfile.tmp
git commit
On branch main
nothing to commit, working tree clean
overwrite
M main/basics/reset/myfile.tmp
write
M main/basics/reset/myfile.tmp
git diff
diff --git a/main/basics/reset/myfile.tmp b/main/basics/reset/myfile.tmp
index f70f10e..90659bd 100644
--- a/main/basics/reset/myfile.tmp
+++ b/main/basics/reset/myfile.tmp
@@ -1 +1,2 @@
-A
+B
+C
git commit
On branch main
nothing to commit, working tree clean
Last update: 432 days ago