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.
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.
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
Git maintains a history of committed changes. Developers can inspect previous commits to understand how a project has changed over time.
git log
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
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.
Git can combine changes from one branch into another branch. This process is called merging.
git merge feature-login
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 .
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"
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.
Git supports remote repositories. A remote repository can be hosted on services such as GitHub or other Git hosting platforms.
git remote -v
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.
The git pull command gets changes from a remote repository and integrates them into the current branch.
git pull origin main
The git fetch command downloads information from a remote repository without directly integrating those changes into your current branch.
git fetch origin
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.
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.
Git provides git diff for examining differences between versions or repository states.
git diff
This can help you review modifications before creating a commit.
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.
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.
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.
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
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.
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.
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.
Git supports team development through branches, commits, merges and remote repositories.
These features allow developers to organize work and share changes.
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.
Git provides commands for examining repository history and individual commits.
git log
git show <commit-id>
These commands can help developers understand previous changes.
Git is available for major operating systems including Windows, macOS and Linux.
This makes Git useful for developers working in different development environments.
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"
Git can manage many types of software projects, including:
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.
Question: Which Git feature is used to maintain a separate line of development?