-
git config --global user.name 'name'
-
git config --global user.email 'email'
-
git config --global core.editor=code --wait
git config --global core.autocrlf=input
-
git config --list
git config user.name
-
git init
-
only single file
git add file name
-
stage all changed file in directory and subdirectory
git add --all
-
shorthand for --all [using latter]
git add -A
-
stage all changed file in directory but not subdirectory
git add *
-
stage all changed file in directory but not subdirectory
git add .
-
directory wildcard
git add *.js
-
directory and subdirectory wildcard
git add **/*.js
-
file name are same like track
git rm --cached file
git rm -f --cached file
git rm -r --cached file
git rm -rf --cached file
-
git diff
git diff --staged
-
git restore file
-
For Moving staging to local repository we can use following command [message should be clear and understandable]
git commit -m 'message here'
-
Staging and commit directly
git commit -am 'message here'
-
git log
git log --oneline
-
if all you want to do is undo the act of committing, leaving everything else intact
git reset --soft HEAD^
-
if all you want to do is undo the act of committing, and also removing from the stagging area
git reset HEAD^
-
If you actually want to completely undo it, throwing away all uncommitted change, resetting everything to the previous commit [as the original question asked]
git reset --hard HEAD^
-
git show
git show <commit_id>
git show HEAD
git show HEAD~[number]
-
git checkout file
git checkout commit-id
.env
*.txt
!main.txt
list?.txt
node_modules/