How do you add changed files from your Git workspace to Staging Area (Index)?
Experience Level: Junior
Tags: GitSource control
Answer
Before you start adding changes to Staging area (Index), it is good idea to first check what changes you have in your workspace. This can be done by executing the following command from command line:
git status
You can then add changes to Index by using git add
command.
The following command adds all changes from the current directory and all its children:
git add .
The following command adds all html files from the folder Views that have some changes:
git add Views\*.html
The following command adds file index.html:
git add index.html
Related Git job interview questions
What is the most basic Git workflow that you can use every day?
GitSource control JuniorWhat is a workspace in Git?
GitSource control JuniorWhat is .git folder?
GitSource control JuniorHow do you check what files are changed in your Git workspace?
GitSource control JuniorWhat is Staging Area (or Index) in Git?
GitSource control Junior