πŸŽ‰ Special Offer !    Code: GET300OFF    Flat β‚Ή300 OFF on every Java Course
Grab Deal πŸš€

Adding Files to Staging - git add


Introduction

  • git add command is used to add changes from the working directory to the staging area.
  • It marks files for inclusion in the next commit, preparing them for version control.
  • Below is the diagram represents the working of git add command :- Git Working

How to use git add ?

  1. Open the Git terminal (or command prompt) and navigate to the project folder where your Git repository is initialized.
  2. Run the git add command:
    git add aaa.txt
  3. The command will show the following:
    • Git Status Command
    • Similarly you can add bbb.txt file in staging area by command git add bbb.txt

Different ways to use git add ?

  1. Stage a Specific File:
    • git add filename.txt
    • This adds filename.txt to the staging area.
  2. Stage Multiple Files:
    • git add file1.txt file2.txt
    • Stages both file1.txt and file2.txt.
  3. Stage All Files:
    • git add .
    • Adds all modified, new and deleted files to the staging area.
  4. Stage Files by Pattern:
    • git add *.txt
    • Stages all .txt files.
  5. Stage Files by Pattern:
    • git add *
    • Stages all files in the current directory, including new, modified and deleted files, except ignored ones.