Skip to content

imon360/git-learn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

Git & GitHub

Config Your Local Machine

  1. set user name

    git config --global user.name 'name'
  2. set user email

    git config --global user.email 'email'
  3. set other...

    git config --global core.editor=code --wait
    git config --global core.autocrlf=input
  4. check config

    git config --list
    git config user.name

Git Start

  1. Git Initializing

    git init
  2. Git Staging [Track]

  • 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
  1. Git UnStaging [Untrack]

  • 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
  1. Show changes between commits, commit and working tree, etc

    git diff
    git diff --staged
  2. discard changes in working directory

    git restore file
  3. local repository [commit]

  • 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'
  1. to see the commit history

    git log
    git log --oneline
  2. how to uncommit

  • 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^
  1. show commit HEAD

    git show
    git show <commit_id>
    git show HEAD
    git show HEAD~[number]
  2. undo modified & commit log change

    git checkout file
    git checkout commit-id
  3. you need ignore file and folder create .gitignore file

 .env
 *.txt
 !main.txt
 list?.txt
 node_modules/

About

Git and GitHub Learn...

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published