Table of contents
- What is Git?
- Features of Git
- What is Github?
- Features of GitHub
- What is Version Control ?
- What is Version Control? How many types of version controls we have?
- Centralized Version Control System
- Distributed Version Control System
- Why we use distributed version control over centralized version control?
- Step-1 Install Git on your CentOs Linux Instance:
- Step-2 Check Git and its Version:
- Step-3 Configure Username and Email id
What is Git?
Git is a modern and widely used distributed version control system in the world. It is developed to manage projects with high speed and efficiency.
Git is an open-source distributed version control system. It is designed to handle minor to major projects with high speed and efficiency. It is developed to co-ordinate the work among the developers. The version control allows us to track and work together with our team members at the same workspace.
Features of Git
Some remarkable features of Git are as follows:
What is Github?
GitHub is a Git repository hosting service. GitHub also facilitates with many of its features, such as access control and collaboration. It provides a Web-based graphical interface.
It offers both distributed version control and source code management (SCM) functionality of Git. It also facilitates with some collaboration features such as bug tracking, feature requests, task management for every project.
Features of GitHub
Some of its significant features are as follows.
Collaboration
Conversations
Integrated issue and bug tracking
Team management
Git repositories hosting
Project management
Graphical representation of branches
Track and assign tasks
Code hosting
What is Version Control ?
A version control system is a software that tracks changes to a file or set of files over time so that you can recall specific versions later. It also allows you to work together with other programmers.
The version control system is a collection of software tools that help a team to manage changes in a source code. It uses a special kind of database to keep track of every modification to the code.
What is Version Control? How many types of version controls we have?
-
Centralized Version Control System
Centralized version control systems have many benefits, especially over local VCSs.
Everyone on the system has information about the work what others are doing on the project.
Administrators have control over other developers.
It is easier to deal with a centralized version control system than a localized version control system.
A local version control system facilitates with a server software component which stores and manages the different versions of the files.
Distributed Version Control System
In a Distributed Version Control System (such as Git, Mercurial, Bazaar or Darcs), the user has a local copy of a repository. So, the clients don't just check out the latest snapshot of the files even they can fully mirror the repository. The local repository contains all the files and metadata present in the main repository.
Why we use distributed version control over centralized version control?
Centralized Version Control System | Distributed Version Control System |
In CVCS, The repository is placed at one place and delivers information to many clients. | In DVCS, Every user has a local copy of the repository in place of the central repository on the server-side. |
It is based on the client-server approach. | It is based on the client-server approach. |
It is the most straightforward system based on the concept of the central repository. | It is flexible and has emerged with the concept that everyone has their repository. |
In CVCS, the server provides the latest code to all the clients across the globe. | In DVCS, every user can check out the snapshot of the code, and they can fully mirror the central repository. |
CVCS is easy to administrate and has additional control over users and access by its server from one place. | DVCS is fast comparing to CVCS as you don't have to interact with the central server for every command. |
The popular tools of CVCS are SVN (Subversion) and CVS. | The popular tools of DVCS are Git and Mercurial. |
CVCS is easy to understand for beginners. | DVCS has some complex process for beginners. |
If the server fails, No system can access data from another system. | if any server fails and other systems were collaborating via it, that server can restore any of the client repositories |
Step-1 Install Git on your CentOs Linux Instance:
1. sudo yum install git
Step-2 Check Git and its Version:
which git
git --version
Step-3 Configure Username and Email id
config --global
user.name
git config --global
user.email
<
Email.id
>
Step-4 Checking details:
git config --list
Step-5 Creat Account on Git hub :
Define Workspace, Staging area and repositories in Git:
Workspace: The workspace, also known as the working directory, is the directory on your local machine where you make changes to your files. This is the place where you modify, create, or delete files as you work on your project.
Staging Area: The staging area, also known as the index, is an intermediate step between the workspace and the repository. When you make changes to your files in the workspace, you can add them to the staging area to prepare them for committing. The staging area allows you to review and select the changes you want to commit and exclude any changes that you don't want to commit.
Repository: A repository is the place where Git stores the history of your project. It contains all the versions of your files and their complete change history. You can have multiple repositories for a project, including local repositories on your machine and remote repositories on servers.
Step-1 Creat a Directory and Initializes it :
git init
git init <name of directory> , if you are not in working directory
Step-2 Creat a file and add it to local repo:
touch devops
git add . <file name>
Step-3 Now if you your file is ready to commit , you can see the status as well.
git status
Step-4 You can see here this file is now ready to commit. so just commit it :
git commit -m "Your message"
Step-5 Just add the central repository here so that you can push your file in Central repo:
At first just copy the link of your central repo on Github account:
Execute command:
git remote add origin <https link>
Step-6 Now try to push it into central repo:
git push -u origin master
git push -u <branch name> , if you are in branch
it will ask for username and password just go to Github account and create token and use it for both username and password:
go to <setting> than <developer setting>
Generate classic token :
Now you can check it onto your Git hub Account:
To pull it from github use following command:
git pull origin master
Note: At present we are on master so we are using origin master, now what if we creat a branch and then try to push it into github lets see:
Creating Branch :
In Git, a branch is a lightweight movable pointer to a commit. Branches are used to create a separate line of development, allowing changes to be made to a codebase without affecting the main codebase until the changes have been tested and merged.
Creating a new branch in Git is a quick and easy process. When you create a new branch, you essentially create a new pointer to the current commit that you are working on. You can then make changes to the codebase, and all of those changes will be made on the new branch.
Branch Creation:
git branch <branch name>
To enter into branch which you have created and to check where you are at present:
git checkout <branch name>
git branch
Here ,You can see at first , I was in master branch denote with * then I switch into branch1 using the checkout command:
now create a file in it and add it to commit
Now just try to push my new branch into Central Repository:
git push -u origin <branch name>
You can see it in your Github Account:
Like share Subscribe to my channel
Subscribe to my newsletter
Read articles from Uzairbagwan's blog directly inside your inbox. Subscribe to the newsletter, and don't miss out
#devops #trainwithshubham #linux #90daysofdevops #aws #learn