Lesson 5 of 60 – Features of Git
8%

Features of Git

Git provides many features that make it useful for managing source code and other project files. It is designed to track changes, support different development workflows, and allow developers to work with local and remote repositories.

Note: Git's features become more useful when you understand repositories, commits, branches, remotes and merging. These concepts will be covered throughout this tutorial.

1. Distributed Version Control

Git is a distributed version control system. Each cloned repository can contain the information needed to work with the project's version history locally.

This allows many Git operations to be performed without continuously communicating with a central server.

2. Fast Performance

Git is designed to perform many operations efficiently. Operations such as checking status, viewing history and creating commits are commonly performed locally.

git status
git log

3. Version History

Git maintains a history of committed changes. Developers can inspect previous commits to understand how a project has changed over time.

git log

4. Branching

Git provides branches for maintaining separate lines of development. A developer can create a branch for a feature or experiment without making those changes directly in another branch.

git branch feature-login

5. Easy Branch Switching

Git allows developers to switch between branches. Modern Git provides the git switch command for this.

git switch feature-login

This makes it convenient to move between different lines of development.

6. Merging

Git can combine changes from one branch into another branch. This process is called merging.

git merge feature-login

7. Staging Area

Git provides a staging area where you can select changes that should be included in the next commit.

git add index.html

You can also stage multiple changes:

git add .

8. Atomic Commits

Git allows you to create commits containing a specific set of staged changes. This makes it possible to organize project history into meaningful steps.

git commit -m "Add login form"

9. Local Commits

Commits are created in the local repository. You do not have to push every commit to a remote repository immediately.

git add .
git commit -m "Update homepage"

The changes can be pushed to a remote later.

10. Remote Repository Support

Git supports remote repositories. A remote repository can be hosted on services such as GitHub or other Git hosting platforms.

git remote -v

11. Push Changes

The git push command sends local commits to a configured remote repository.

git push origin main

This is commonly used to share local commits with a remote repository.

12. Pull Changes

The git pull command gets changes from a remote repository and integrates them into the current branch.

git pull origin main

13. Fetch Changes

The git fetch command downloads information from a remote repository without directly integrating those changes into your current branch.

git fetch origin

14. Clone Repositories

Git can create a local copy of an existing repository using git clone.

git clone https://github.com/username/project.git

This is commonly used when starting work with an existing remote project.

15. Track Changes

Git can show which files have been modified, added or removed.

git status

The status command is one of the most commonly used Git commands.

16. Compare Changes

Git provides git diff for examining differences between versions or repository states.

git diff

This can help you review modifications before creating a commit.

17. Restore Changes

Git provides the git restore command for restoring files in certain working-tree or staging-area situations.

git restore index.html

Always review the command and its scope before discarding changes.

18. Revert Commits

The git revert command creates a new commit that reverses the effect of an earlier commit.

git revert <commit-id>

This is different from simply deleting a commit from history.

19. Git Stash

Git provides stash for temporarily storing certain uncommitted changes so you can work on something else.

git stash

Stashed changes can later be applied or restored.

20. Tags

Git tags can be used to mark specific points in repository history. They are commonly used to identify releases or important versions.

git tag v1.0.0

21. Git Ignore

Git supports a .gitignore file for specifying files and directories that should normally not be tracked.

node_modules/
.env
*.log

The exact patterns depend on the project.

22. Data Integrity

Git uses cryptographic hashes for identifying repository objects. This helps Git detect unexpected changes to stored repository data.

Git commit and object identifiers are based on repository content.

23. Offline Development

Many Git operations can be performed without an internet connection.

git status
git add .
git commit -m "Local update"
git log

Internet access is generally required when communicating with a remote repository.

24. Collaboration Support

Git supports team development through branches, commits, merges and remote repositories.

These features allow developers to organize work and share changes.

25. Lightweight Branching

Git branches are designed to make it practical to maintain separate development paths.

git branch feature-profile
git switch feature-profile

A branch can later be merged into another branch.

26. Powerful History Inspection

Git provides commands for examining repository history and individual commits.

git log
git show <commit-id>

These commands can help developers understand previous changes.

27. Cross-Platform Support

Git is available for major operating systems including Windows, macOS and Linux.

This makes Git useful for developers working in different development environments.

28. Git Configuration

Git can be configured according to the developer's needs. For example, you can configure your name and email:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

29. Git Works with Many Project Types

Git can manage many types of software projects, including:

  • Web development projects
  • PHP projects
  • Python projects
  • Java projects
  • C and C++ projects
  • JavaScript projects
  • Documentation projects

30. Summary of Git Features

Git provides a powerful collection of features for managing software projects. Its distributed architecture, branching, commits, staging, remote repositories and history management make it useful for both individual and team development.

In the next lesson, we will learn how to install Git on a computer.

📌 Key Points

  • Git is a distributed version control system.
  • Git provides fast local operations.
  • Git maintains project history through commits.
  • Git supports branches and merging.
  • The staging area helps select changes for commits.
  • Git supports remote repositories.
  • git push sends commits to a remote repository.
  • git pull gets and integrates remote changes.
  • git fetch downloads remote information without directly integrating it.
  • Git supports tags, stash and .gitignore.
  • Git can be used offline for many operations.
  • Git works with many programming languages and project types.

🧠 Quick Quiz

Question: Which Git feature is used to maintain a separate line of development?