Git 101: A Beginner-Friendly Guide
Languages and Frameworks keep on changing, but Git has remained the same for the past few years and is used for version control. Whether working in a team or individually, Git is a must to use to keep track of changes.
In this guide, we will start from the basics: what Git is, why it’s used, how to install it and we will learn about various Git commands and Git Workflow.
What is Git?
Git is a distributed version control software system that is capable of managing versions of code.
It lets us to:
- Track Every changes
- Collaborate with others
- Allows going back to previous versions.
Git Installation:
Before moving further, let’s first do the installation from the official website of Git. Try to keep the default settings.
Configure Git:
After installing Git, it needs to be configured. Git records the author’s name and email for every change (commit) made in a project. Without this configuration, the author of the changes cannot be properly identified.
Commands used for configuration are:
git config --global user.name "Your Name"
git config --global user.email "you@example.com"Explanation of the Git Config Commands Step by Step:
- git- This is used to tell the system to use Git software for version control.
- config- This is used to set the settings that control how git looks and operates.
- --global- This is a flag that is used to define the scope. It is used to set the same name for all the git repositories.
- user.name- This is the specific setting key that is being set to change.
Here, user refers to the category of settings like git has multiple settings like color, editor but in this specifically refers to the user category.
.name- This is a specific setting inside the user category to tell Git that this particular setting needs to be updated with the author’s name.
.email- This is the specific setting inside the user category for the author’s Email ID - “Your Name”- This is the actual value that needs to be updated with the author’s name.
- “you@example.com”- This is the actual value that needs to be updated with the author’s email address.
Common Git Commands:
- git init
Initialise a new Git repository in the current directory
git init2. git status
Displays the state of the working directory and staging area.
git status3. git add
Adds changes to the staging area
git add filename4. git commit
Records changes to the repository
git commit -m "Message"5. git log
Shows the commit history.
git log6. git remote
Manages remote repository connections.
git remote add origin github_repo_link7. git remote -v
Lists the URLs of remote repositories.
git remote -v8. git push
Get Jaspinder kaur Walia’s stories in your inbox
Join Medium for free to get updates from this writer.
Send changes to a remote repository
git push origin main9. git pull
Fetches and merges changes from a remote repository.
git pull origin main10. git fetch
Downloads changes from a remote repository without merging.
git fetch origin11. git merge
Combines changes from one branch into another.
git merge branch_name12. git branch
Lists or creates a new branch.
git branch branch_name13. git checkout
Switches between branches.
git checkout branch_name14. git clone
Copies a remote repository to the local machine.
git clone github_link15. git stash
Save uncommitted changes.
git stash16. git stash pop
Applies and removes stashed changes.
git stash pop 17. git reset
Unstages changes or resets commits.
git reset HEAD filenameGit Workflow:
It provides a step-by-step process for moving code from the local repository to the remote repository.
- Firstly, changes are made in the working directory where the code is written and edited.
- Next, move the selected files to the staging area. This stage allows to choose which changes should be included in the next commit.
- Then by using git commit save the changes to the local repository with a meaningful message.
- Lastly, use the git push command to upload the commits to the remote repository making the code available to other developers.
Git vs Github:
Git and GitHub are commonly used together, but they are different.
- Git is a software that needs to be installed on the system and then can be used for version control.
- GitHub is a platform used to host and manage code and can also be used to deploy applications.
Tips for Beginners:
- Always use the pull command before the push command.
- Write clear and meaningful commit messages.
- Add files before commit.
- Try to use different branches instead of using only a single main branch.
To know more about Git, can explore the official git documentation.







