GIT – Version Control System
What is version control system?
A version control system is nothing but a simplified sytem developed to manage and control all the versions of our code simultaneously. With the help of version control it is easy to fall back to previous versions in case we ever end up to a faulty or a bugged build of our program.
Not only does version control act as a restore point for our code, it also help remote workers to split the task and work on code simultaneously. This act as an isolation mode for developers to also not conflict or eradicate each other’s code.
There are many different version control systems available in 2021, but today we’re only going to focus on GitHub.
How to set up GitHub on Centos 7 machine? {without ssh}
First go to github.com and create an account with the on screen steps.
After successful account creation and verification, open your centos machine. Gain access to root user using command below. this will be needed for steps explained later in article :
$ Sudo -i
After entering root password and successful authentication you will see a # sign at the beginning of your command line.
Next install git from yum repository on your centos machine using :
# yum install git -y
To verify git has successfully installed write :
#git –version
After successful installation of git package, we configure git credentials to git config files using :
# git config –global user.name “Your Name”
# git config –global user.email “you@example.com”
To cross check if our values are inserted correctly, we run :
# git config –list
If everything is inserted correctly we will receive a response as :
user.name=username
user.email= username@some-domian.com
This is it. Github is installed and is ready to use. Now we clone a git in our specific folder. For this first we go into the project folder of our wish or create a new :
# cd project
now we run init command to use our present directory as our git repo :
# git init
After git init enter into directory. Now to clone the directory first copy the github clone link from official website’s repo :
Now on centos machine, type :
# git clone https://github.com/drsinger/testrepo.git
now select the branch you want to work in. To see all availabe branches type :
# git branch
To switch to a particular branch :
# git checkout “branch name”
To create a new branch :
# git branch “branch name”
Now we can work in our new branch with our new files. After working on branch, we need to add files to our repo :
# git add .
After adding files we need to mention a commit to our changes :
# git commit
If our branch is preexisting branch on out git repo we apply :
# git push
If our branch is non existent on our online git repo we need to type :
# git push origin “branch name”
After this our branch is uploaded on github server with all the saved changes. If we want to merge our new branch to an existing branch we need to type :
# git merge “ branch name to merge ”
With this you now should had your github setup and running in your centos machine. there are various other ways to connect to your github repo as well. We will cover them in future posts.