0% found this document useful (0 votes)
14 views

Devops Exercise-4

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Devops Exercise-4

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Exercise4:

Modulename:ImplementationofCICDwithJavaandopen-sourcestack
ConfigurethewebapplicationandVersioncontrolusingGitusingGitcommandsand version
control operations.

Whatis GIT?

Git is a free open-source distributed version control system you can use to track
changesinyourfiles.YoucanworkonalltypesofprojectsinGit,fromsmalltolarge.

WithGit,youcanaddchangestoyourcodeandthencommitthem(orsavethem)when you're
ready. This means you can also go back to changes you made before.

GitworkshandinhandwithGitHub–sowhatisGitHub?

WhatisGitHub?

GitHubisawebinterfacewhereyoustoreyourGitrepositoriesandtrackandmanage
yourchanges effectively.Itgivesaccess tothecodetovariousdevelopersworkingon the
same project. You can make your own changes to a project at the same time as other
developers are making theirs.

Ifyouaccidentally messupsomecodeinyourprojectwhilemakingchanges,you can easily


go back to the previous stage where the mess has not occurred yet.

WhyuseGitHub

There are so many reasons you should learn and use GitHub. Let's look at a few of
them now.

EffectiveProjectManagement

GitHub is a place where your Git repositories are stored. GitHub makes it easy for
developers working on the same project but in different locations to be on the same
page.

With GitHub,you can easilytrack and managethechangesyouhavemadeand check on


the progress you've made in your project.

DepartmentofCSE pg.21
EasyCollaborationandCooperation

WithGitHub,developersfromallovertheworldcanworktogetheronaproject without having


any problems.

Teams are able to stay on the same page while working on a project together and can
easily organize and manage the project effectively.

Open Source

GitHubisafreeandopen-sourcesystem.Thismeansthatdeveloperscaneasilyaccess
different types of code/projects which they can use in learning and developing their
skills.

Versatility

This attribute of GitHub is very important. GitHub is not a web interface for only
developers. It can be used by designers, writers, and anyone who wants to keep track
of the history of their projects.

HowtoSetupGit

TostartusingGit,you'll needtodownload it to yourcomputerifyou haven't already. You


can do this by going to their official website.

When Git opens, scroll down a bit and you should see a download button. Go ahead
and click on it.Download button on the Git website

Chooseyouroperatingsystemwhetherit'sWindows,MacOS,Linux/Unix.Inmy case,
I will be choosing the Windows option because I am using a Windows computer:

DepartmentofCS E 22
fCSE
Chooseyouroperatingseeyousystem
ClickonthefirstlinkattheverytopofthepagetodownloadthelatestversionofGit.

DownloadthelatestversionofGitbyclickingthefirstlink
Whenthedownloadiscomplete,thengoaheadandinstallGittoyourcomputer.You'll need
to go to the location where the file has been downloaded and install it.

Aftertheinstallation,you'llwanttomakesurethatGitissuccessfullyinstalledonyour
system. Open your command prompt or Git bash (whichever one you choose to use)
and run the command:

DepartmentofCSE pg.23
git--version

IfGitwassuccessfullyinstalledonyourcomputer,itshoulddisplaythecurrentversion of Git
below the command you just ran. If the current version is being displayed,
congratulations!

HowtoConfigureGit
Now that we have installed Git on our computer, we have to configure it. We do this
so that any time we are working in a team on a project, we can easily identify the
commits we have made in the repository.

To configure Git, we need to specify the name, email address, and branch by usingthe
git config --global command. For example:

From the image above, we used git config --global user.name to configure the
username.InmycaseIusedmyname “DerekEmmanuel”.Thesameappliesforthe git
config --global user.email.

Gitcomeswithadefaultbranchofmaster,soI changedittobecalledthemainbranch by using


the git config --global init.default branch main command.
Nowyou'rereadytostartusingGit.

DepartmentofCSE pg.24
Howto Setupa GitHubAccount
TosetupaGitHubaccount,visittheir officialwebsite.Clickonthesign upbuttonin
the upper right corner:

Whenthesignupformopensup,enteryouremail,createapassword,enteryour
username, and then verify your account before clicking on the create account
button.
CreateyourGitHubaccount
CommonlyUsedGitCommands
TherearesomebasicGitcommandsthateverydevelopershouldknowhowtouse:

 gitconfig
 gitinit
 gitadd
 gitcommit
 gitclone
 git push
 gitrm
 gitbranch
Let'sgothrougheachofthesebrieflysoyouknowhowtousethem.

HowtoUsethegitconfigCommand

Youusethiscommandtosettheusername,email,andbranchofausersoastoidentify
whomadeacommitwhenworkingonaproject.Thiscommandisusedwhenyouhav
e downloaded git into your computer and you want to customize it for your
use.

Forexample:

gitconfig--globaluser.name“[username]”
gitconfig--globaluser.Email[emailaddress]

HowtoUsethegitinitCommand

You use the git init command to start Git in your project. This git command
is used
whenyouareworkingonaprojectandwouldliketoinitializegittotheprojectinorder
to keep track of the changes made in the project.

Forexample:itinit

Whenyourunthiscommand,youshouldseeafoldernamed.gitbeingcreatedautomatic
ally in the current folder you are working on.

HowtoUsethegitaddCommand

This command adds your file to the staging area. The staging area is the area
where files we make changes to are added and where they wait for the next
commit.

To add a file to the staging area, you use the git add command. It adds all the files in the folder to the
staging area.

gitadd(filename)addsthenameoftheparticularfileyouwanttocommitinthe staging
area.

Usethiscommandwhenyouhavemadechangestoafileandwanttocommitthemto
your project.

HowtoUsethegitcommitCommand

Thiscommitsanyfileyouaddedwiththe gitaddcommandaswellaseveryfileinthe
staging area.

Forexample:

gitcommit–m“firstcommit”
This command saves a file permanently to the Git repository. You use it
whenever a file has been added to the staging area using the git add
command.

HowtoUsethegitcloneCommand

You use thegit clonecommand to copy an existing repository in another


location to the current location where you want it to be.

Forexample:

gitclone(repositoryname)
YouusethiscommandwhenyouwanttoduplicateaGitrepositoryfromGitHubinto
your local storage.
HowtoUsethegitpushCommand

Youusethiscommandtoupload/pushfilesfromthelocalrepository/storagetoanother
storage, like a remote storage such as GitHub.

Forexample:

gitpush(remotestoragename)
Youonlyusethiscommandwhenyou'resatisfiedwiththechangesandcommitsyou've
made on a project and finally want to upload/push it to the Git repository in
GitHub.

HowtoUsethegitrmCommand

YouusethisGitcommandtoremoveafilefromaworkingrepository.Forexample:

git rm (filename)

Youusethiscommandonlywhenyouwishtogetridofanunwantedchanges/
filefrom the Git repository.

HowtoUsethegitbranch Command

You usethis command to check thecurrent branch you are


working on, either main or master.

Forexample:
gitbranch
Thiscommandhelpsyouknowthecurrentbranchyouareworkingon.

Conclusion
Inthistutorialyoulearnedwhatversioncontrolsystemsareallabout.Youalsolearn
ed
howtoinstallandsetupGitonyourcomputerandsetupaGitHubaccount.Lastly,we
went through some commonly used Git commands.

You might also like