Git:- “git add .”

Background

Quick Reminder on why not to quickly take pointers.

Git Sessions

Outline

  1. Session – 01
    • git add
      • git add .
    • git commit
    • git reset
  2. Session – 02
    • git add
      • git add <filename>
    • git status
    • git commit
    • git push

Session – 01

git add

Issued “git add .

git commit

Issued git commit.

My editor of choice launched and all of the files in my working folder and sub-directories were listed.

Seemingly issuing “git add .” means to add all files.

git reset

Issued “git reset” to discard all the files staged for local commit.

 

Session – 02

 

git add <filename>

Issued “git add <filename>“.

The filename is the name of the file to commit.

git status

Issued “git status” to review the list of files that will be “locally” committed.

Output

Output – Text
>git status
On branch master
Your branch is up to date with 'origin/master'.

Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   file01.sql

Output – Image

git commit

Issued git commit.

Once again, reviewed the list of files that will be committed.

Thankfully, this time, only the lone file.

Added a verbose commit message to indicate this is an important change.

 

git push

Issued git push to commit remotely.

 

Summary

Please be mindful that “git add .” implies adding all files in the current working folder, as well as subfolders.

If you prefer you can also consider using a gitignore file to expressly ignore specific folders and files.

Hopefully, you are not using your git repository as a backup folder.

 

References

  1. Git-SCM

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s