Git 101
- Omkar Vishwakarma
- Apr 2
- 2 min read
Updated: Apr 3
Git Basic Intro:
Git is a distributed version control system (VCS) used to track changes in source code and collaborate on software development. It allows multiple developers to work on a project simultaneously, keep track of modifications, and revert to previous versions if needed.
Similar to Git, there are other centralized version control system tools as well like CVS, SVN, but Git is the most widely used Version Control System.
Key features of git include branching, merging, reverting to previous versions
Git and Github
Git and Github are not the same thing
Git is a software.
Github is a service provided by a company to store your project repository online.
You can use git without Github, but you cannot use Github without the using git.
There are many other alternatives to Github like Bitbucket, Gitlab.
Git Terminologies:
Repository: (also called as repo) is a folder containing your files.
Working Directory – The local environment where files are modified before being tracked by Git.
Staging Area: (also called the index) is a temporary space where changes are added before committing them to the repository. It allows you to carefully select and organize changes before making a commit, ensuring only specific modifications are included.
Local Repository – A Git repository stored on your computer containing commit history.
Remote Repository – A centralized Git repository hosted on a server (e.g., GitHub, GitLab).
Branches – Independent lines of development that allow parallel work in a Git repository.
Pull Requests – A request to merge changes from one branch to another in a remote repository.
Merge – The process of combining changes from different branches into a single branch.
Install git and setup GitHub account
Git Commands:
git --version
This command will display the version of git utility running on your machine.
omkarvishwakarma> git --version
git version 2.34.1
git config --global user.name "FIRST_NAME LAST_NAME"
git config --global user.email "MY_NAME@example.com"
This command is used to set the global Git username & email that will be associated with your commits. This username appears in the commit history.
It identifies you as the author of commits across all repositories on your system.
omkarvishwakarma> git config --global user.name "John Doe"
omkarvishwakarma> git config --global user.email "john.doe@example.com"
git config --list
This command displays all Git configuration settings on your system. Used to check your user details (user.name, user.email).
git init
This command is used to initialize a git repository while inside the working directory, This allows git to start tracking changes in the directory.
It creates a hidden git folder in the working directory as seen below in the screenshot
We created an empty directory - gitpractice and initialized the repository using git init command.
コメント