What does a version control system do?

<aside> 💡

By keeping track of the changes that we make to our files, a VCS lets us know when a file changed, who changed it, and also lets us easily roll back those changes.

</aside>

General form of commands

Git <git-options> <commands> <command-options> <operands>

.git directory

The git directory acts as a database for all the changes tracked in Git and the working tree acts as a sandbox where we can edit the current versions of the files.

Staging area (index)

A file maintained by Git that contains all of the information about what files and changes are going to go into your next commit

Screenshot 2026-07-26 at 1.41.41 PM.png

What do we need to do after modifying a file tracked by Git?

<aside> 💡

After modifying a file, we need to stage those changes and then commit them afterwards.

</aside>

Initialize new git repository in your system

mkdir scripts
cd scripts

# The Git init command can create a new empty repository in a current directory
git init

# The ls-l.git command checks inside the directory to see the different things that it contains. This is called the Git directory. 
# The Git directory is a database for your Git project that stores the changes and the change history.
ls -l .git

git config -l

touch disk_utility.py

# The Git status command is used to get some information about the current working tree and pending changes.
git status

# This command will immediately move a new file from untracked to stage status
# Using the Git add command allows Git to track your file and uses the selected file as a parameter when adding it to the staging area. 
# The staging area is a file maintained by Git that contains all the information about what files and changes are going to go into your next commit.
git add disk_utility.py

# When a file is staged, it means it's been added to the staging area and it's ready to be commited to the Git repository
git status

# This command will only commit the changes that have been added to the staging area, untracked files or 
# modified files that weren't staged will be ignored
# The .git commit command is run to remove changes made from the staging area to the .git directory. 
# When this command is run, it tells Git to save changes. A text editor is opened that allows a commit message to be entered.
git commit -m "new file"

# View Git commit history
git log

Telling git who you are & global settings

# The Git config command is used to set the values to identify who made changes to Git repositories
git config --global user.name "Senthil Palanivelu”
git config --global user.email "[email protected]"

git config --global core.editor vim
git config --global core.autocrlf input
git config --global help.format web
git config --global diff.tool vimdiff
git config --global merge.tool vimdiff
git config --global difftool.prompt false
Git config —-global merge.conflictstyle diff3

Check global configuration settings in user home directory

cat ~/.gitconfig or git config —-global —-list

Creating alias for long commands

git config <scope option> alias.<name> <command string>
git config --global alias.hist 'log --pretty=format:"%h ( %ad %an ) %s %d" --graph —-date=short —-name-only’
git config --global alias.globallist 'config --global --list'

Staging scope, Moving files from working directory to staging area