Git add

The git add command is like picking up specific pictures from your messy desk(Working Directory) and putting them on the table(Staging Area) to prepare for saving.

git add demo.txt

This command stages the changes made to demo.txt and gets it ready for the next commit.

Screenshot 2024-08-10 at 2.17.10 AM.png

To stage more than one file at a time using git we can use-

git add --all or git add .

This will stage all changes (new, modified, and deleted) files in the working directory.

Git commit

The git commit command is like taking the changes from the table (staging area) and permanently saving them in the album (repository).

This command commits (saves) the staged changes with a message describing what you did, like a label for the photo in your album.

git commit -m "message”
Screenshot 2024-08-10 at 2.19.08 AM.png

Git Commit without Stage

We can commit changes directly, skipping the staging environment-

git commit -a -m "message”

The -a option will automatically stage every changed, already tracked file.

Git Commit Log

To view the history of commits for a repository, we can use:

git log
Screenshot 2024-08-10 at 2.28.22 AM.png