0
0
Gitdevops~5 mins

git add with patterns and directories - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the command git add . do?
It stages all changes (new, modified, deleted files) in the current directory and all its subdirectories for the next commit.
Click to reveal answer
beginner
How can you stage all .txt files in the current directory using git add?
Use the pattern git add *.txt to stage all files ending with .txt in the current directory only.
Click to reveal answer
intermediate
What is the difference between git add * and git add .?
git add * stages all files and directories in the current directory but does not include hidden files or files in subdirectories. <br>git add . stages all changes including hidden files in the current directory and subdirectories.
Click to reveal answer
beginner
How do you stage all files inside a specific directory named docs?
Use git add docs/ to stage all changes inside the docs directory and its subdirectories.
Click to reveal answer
intermediate
Can git add use wildcards to stage files recursively in subdirectories?
No, wildcards like *.txt only match files in the current directory. To stage files recursively, use git add . or specify directories.
Click to reveal answer
Which command stages all changes in the current directory and all subdirectories?
Agit add -p
Bgit add *
Cgit add *.txt
Dgit add .
What does git add *.js do?
AStages all JavaScript files in all subdirectories
BStages all files including hidden ones
CStages all JavaScript files in the current directory only
DStages all files except JavaScript files
How to stage all files inside a folder named src?
Agit add src/
Bgit add src/*
Cgit add *.src
Dgit add .src
Which command does NOT stage hidden files?
Agit add .
Bgit add *
Cgit add docs/
Dgit add -A
To stage only modified parts of files interactively, which command is used?
Agit add -p
Bgit add .
Cgit add *
Dgit add --all
Explain how to use git add with patterns to stage specific file types.
Think about how shell wildcards work in file names.
You got /3 concepts.
    Describe how to stage all changes inside a directory and its subdirectories using git add.
    Consider how folders are referenced in commands.
    You got /3 concepts.