How to Use Git
How to Use Git
BDULXKH3CD2J25CK
What is Git?
• Git is a widely used modern version control system for tracking changes in computer files. The
term version control system suggests a system that records all the changes made to a file or
set of data, so a specific version can be considered whenever needed. This feature makes the
process of collaboration so feasible with all team members, making it considerably more
comfortable to work over a big project.
• Git makes it possible for several people involved in the project to work together and track
each other's progress over time. In software development, the tool helps in Source Code
Management. Git favors not only programmers but also non-technical users by keeping track
of their project files.
• While working on Git, we actively use two repositories.
• Local repository: The local repository is present on our computer and consists of all the files
and folders. This Repository is used to make changes locally, review history, and commit when
offline.
• Remote repository: The remote repository refers to the server repository that may be present
anywhere. This repository is used by all the team members to exchange the changes made.
• Both repositories have their own set of commands. There are separate Git Commands that
work on different types of repositories.
git init
• The git status command tells the current state of the repository.
• The command provides the current working branch. If the files are in
the staging area, but not committed, it will be shown by the git status.
Also, if there are no changes, it will show the message no changes to
commit, working directory clean.
• git status
git config
• The git config command is
used initially to configure
the user.name and
user.email. This specifies
what email id and username
will be used from a local
repository.
• When git config is used with
--global flag, it writes the
settings to all repositories
on the computer.
• git config --global user.name
“any user name”
• git config --global user.email
<email id>
git branch
• The git branch command is used to determine what branch the local repository is
on.
• The command enables adding and deleting a branch.
• # Create a new branch
• git branch <branch_name>
• # Delete a branch
• git branch -d <branch_name>
git checkout
• The git checkout command is used to switch branches, whenever the
work is to be started on a different branch.
• The command works on three separate entities: files, commits, and
branches.
• # Checkout an existing branch
• git checkout <branch_name>