GIT ADD

git add is a Git command used to stage changes made to a working directory, before committing them. Staging is an intermediate step that allows you to control which changes are included in the next commit and which are not.

Here is an example:

Suppose you made changes to two files named file1.txt and file2.txt. You want to include the changes to file1.txt in your next commit, but not the changes to file2.txt.
To do so, first navigate to the project directory in the terminal and execute:

git add file1.txt

This command stages the changes made to the file file1.txt. You can now review the changes staged by executing:

git status

You should see that file1.txt has been staged.
Now you can commit the staged changes by running:

git commit -m "Added new feature to file1.txt"

The commit will include only the changes to file1.txt since file2.txt was not staged.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.