Core Concepts & Resources

Commands

  • Starting point
    # your global user acc 
    git config --global user.name "name"
    git config --global user.email "test@gmail.com"
     
    # Get the user acc
    git config --list --show-origin
    git config user.name
    git config user.email
     
    # Edit 
    git config --global --edit
     
    # Unset 
    git config --global --unset user.name
    git config --global --unset user.email
    • Init
      git config --global init.defaultBranch main # chainging the master to main 
      git init
      git submodule update --init --recursive # Update submodules 
      git status # status of the repo
       
       
    • Adding
      git add index.html # file 
      git add . # all files 
      git add .gitmodules PowerShell/ADModule # Adding submodules 
    • commit
      git commit -m 'playing'
    • logging
      git log
    • pushing
      Create a repo Then
      git remote add origin https://github.com/name/repo.git
      git branch -M main
      Create PAT token Then
      git config --global credential.helper store # store the creds
      git push -u origin main
       
      # Then
      git add .
      git commit -m "test"
      git push or git push -u origin main
      git push -f origin main
       
      # Tips & Trciks 
      	# Shortcut
      git commit -am "test" # == git add . + git commit -m 
    • Pull
      git pull
      git pull --force # Force Updates
    • Ignoring files
      touch .gitignore # Then add ur files names u wanna github to ignore 
    • Cloning
      git clone 
      git submodule add https://github.com/samratashok/ADModule.git PowerShell/ADModule # add submodules to ur Repo
    • Branch
      git checkout -b feature/login
      git branch
       
      # Then
      git add .
      git commit -m "test"
      git push  -u origin feature/login
       
       
      # Then (Another computer)
      git checkout -b main
      git pull origin main
      git fetch origin # get from remot delet local