GitWebisprettysimplisticthough.Ifyou’relookingforamodern,fullyfeaturedGitserver,thereareseveralopensourcesolutionsouttherethatyoucaninstallinstead.AsGitLabisoneofthepopularones,we’llcoverinstallingandusingitasanexample.ThisisharderthantheGitWeboptionandwillrequiremoremaintenance,butitisafullyfeaturedoption.
GitLabisadatabase-backedwebapplication,soitsinstallationismoreinvolvedthansomeotherGitservers.Fortunately,thisprocessiswell-documentedandsupported.GitLabstronglyrecommendsinstallingGitLabonyourserverviatheofficialOmnibusGitLabpackage.
Theotherinstallationoptionsare:
GitLab’sadministrationinterfaceisaccessedovertheweb.SimplypointyourbrowsertothehostnameorIPaddresswhereGitLabisinstalled,andloginastherootuser.Thepasswordwilldependonyourinstallationtypebutbydefault,OmnibusGitLabautomaticallygeneratesapasswordforandstoresitto/etc/gitlab/initial_root_passwordforatleast24hours.Followthedocumentationformoredetails.Afteryou’veloggedin,clickthe“Adminarea”iconinthemenuatthetopright.
Youcanremoveauseraccountintwoways:“Blocking”auserpreventsthemfromloggingintotheGitLabinstance,butallofthedataunderthatuser’snamespacewillbepreserved,andcommitssignedwiththatuser’semailaddresswillstilllinkbacktotheirprofile.
“Destroying”auser,ontheotherhand,completelyremovesthemfromthedatabaseandfilesystem.Allprojectsanddataintheirnamespaceisremoved,andanygroupstheyownwillalsoberemoved.Thisisobviouslyamuchmorepermanentanddestructiveaction,andyouwillrarelyneedit.
Eachgroupisassociatedwithanumberofusers,eachofwhichhasalevelofpermissionsforthegroup’sprojectsandthegroupitself.Theserangefrom“Guest”(issuesandchatonly)to“Owner”(fullcontrolofthegroup,itsmembers,anditsprojects).Thetypesofpermissionsaretoonumeroustolisthere,butGitLabhasahelpfullinkontheadministrationscreen.
AGitLabprojectroughlycorrespondstoasingleGitrepository.Everyprojectbelongstoasinglenamespace,eitherauseroragroup.Iftheprojectbelongstoauser,theowneroftheprojecthasdirectcontroloverwhohasaccesstotheproject;iftheprojectbelongstoagroup,thegroup’suser-levelpermissionswilltakeeffect.
Everyprojecthasavisibilitylevel,whichcontrolswhohasreadaccesstothatproject’spagesandrepository.IfaprojectisPrivate,theproject’sownermustexplicitlygrantaccesstospecificusers.AnInternalprojectisvisibletoanylogged-inuser,andaPublicprojectisvisibletoanyone.NotethatthiscontrolsbothgitfetchaccessaswellasaccesstothewebUIforthatproject.
GitLabincludessupportforhooks,bothataprojectorsystemlevel.Foreitherofthese,theGitLabserverwillperformanHTTPPOSTwithsomedescriptiveJSONwheneverrelevanteventsoccur.ThisisagreatwaytoconnectyourGitrepositoriesandGitLabinstancetotherestofyourdevelopmentautomation,suchasCIservers,chatrooms,ordeploymenttools.
Thefirstthingyou’llwanttodowithGitLabiscreateanewproject.Youcandothisbyclickingonthe“+”icononthetoolbar.You’llbeaskedfortheproject’sname,whichnamespaceitshouldbelongto,andwhatitsvisibilitylevelshouldbe.Mostofwhatyouspecifyhereisn’tpermanent,andcanbechangedlaterthroughthesettingsinterface.Click“CreateProject”,andyou’redone.
Oncetheprojectexists,you’llprobablywanttoconnectitwithalocalGitrepository.EachprojectisaccessibleoverHTTPSorSSH,eitherofwhichcanbeusedtoconfigureaGitremote.TheURLsarevisibleatthetopoftheproject’shomepage.Foranexistinglocalrepository,thiscommandwillcreatearemotenamedgitlabtothehostedlocation:
Another,moredecoupledwayofcollaborationisbyusingmergerequests.Thisfeatureenablesanyuserthatcanseeaprojecttocontributetoitinacontrolledway.Userswithdirectaccesscansimplycreateabranch,pushcommitstoit,andopenamergerequestfromtheirbranchbackintomasteroranyotherbranch.Userswhodon’thavepushpermissionsforarepositorycan“fork”ittocreatetheirowncopy,pushcommitstotheircopy,andopenamergerequestfromtheirforkbacktothemainproject.Thismodelallowstheownertobeinfullcontrolofwhatgoesintotherepositoryandwhen,whileallowingcontributionsfromuntrustedusers.
Mergerequestsandissuesarethemainunitsoflong-liveddiscussioninGitLab.Eachmergerequestallowsaline-by-linediscussionoftheproposedchange(whichsupportsalightweightkindofcodereview),aswellasageneraloveralldiscussionthread.Bothcanbeassignedtousers,ororganizedintomilestones.
ThissectionisfocusedmainlyontheGit-relatedfeaturesofGitLab,butasamatureproject,itprovidesmanyotherfeaturestohelpyourteamworktogether,suchasprojectwikisandsystemmaintenancetools.OnebenefittoGitLabisthat,oncetheserverissetupandrunning,you’llrarelyneedtotweakaconfigurationfileoraccesstheserverviaSSH;mostadministrationandgeneralusagecanbedonethroughthein-browserinterface.