Home
%3CLINGO-SUB%20id%3D%22lingo-sub-905676%22%20slang%3D%22en-US%22%3EGetting%20Started%20with%20Git%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-905676%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F241897%22%20target%3D%22_blank%22%3E%40Thomas%20Rayner%3C%2FA%3E%26nbsp%3Bshared%20his%20six%20Git%20commands%20for%20beginners%20in%20a%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FITOps-Talk-Blog%2FSix-Git-Commands-Beginners-NEED-To-Know%2Fba-p%2F286891%3FWT.mc_id%3Ditopstalk-blog-salean%22%20target%3D%22_self%22%3Eblog%20post%3C%2FA%3E%2C%20in%20this%20post%20I%20share%20my%20journey%20of%20learning%20Git%2C%20the%20commands%20I%20use%20and%20how%20you%20get%20involved%20further.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIt%E2%80%99s%20one%20of%20those%20tools%2C%20products%20that%20I%20always%20resigned%20to%20being%20within%20the%20developer%20toolbox%20and%20not%20something%20an%20IT%20Pro%20would%20ever%20consider%20using.%26nbsp%3B%20But%20over%20the%20last%20three%20years%2C%20it%E2%80%99s%20become%20one%20of%20those%20tools%20I%20keep%20installed%20on%20my%20machine%20and%20one%20I%20now%20use%20on%20a%20weekly%20basis.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EWhat%20is%20Git%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EGit%20is%20an%20open%20source%20project%2C%20that%20has%20become%20the%20de%20facto%20standard%20tool%20for%20helping%20end%20users%2Forganisations%20with%20their%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fdevops%2Flearn%2Fgit%2Fwhat-is-version-control%3FWT.mc_id%3Ditopstalk-blog-salean%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Eversion%20control%3C%2FA%3E.%20%26nbsp%3B%26nbsp%3BIt%20can%20run%20on%20a%20range%20of%20operating%20systems%20and%20there%20is%20a%20large%20community%20behind%20it%20with%20lots%20of%20documentation%20and%20tutorial%20available.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ELearning%20Git%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20Git%20is%20hard%20to%20learn.%26nbsp%3B%20I%20think%20that%E2%80%99s%20a%20widely%20known%20or%20accepted%20fact%2C%20and%20I%20can%20vouch%20for%20it.%26nbsp%3B%20I%20only%20know%20a%20sub%20section%20of%20its%20functionality%20and%20tricks.%26nbsp%3B%20I%20probably%20do%20things%20in%20the%20less%20effective%20method%20possible%2C%20but%20I%20have%20learnt%20how%20to%20use%20it%2C%20and%20as%20I%20say%20it%E2%80%99s%20become%20something%20I%20use%20at%20least%20once%20a%20week.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EWhy%20learn%20Git%3F%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20I%20said%20earlier%20it%E2%80%99s%20become%20a%20de%20facto%20standard%2C%20for%20hobbyists%20to%20enterprises.%26nbsp%3B%20Regardless%20of%20where%20your%20source%20code%20is%20stored%2C%20Git%20can%20help%20you%20manage%20it.%26nbsp%3B%20And%20it%E2%80%99s%20not%20just%20a%20developer%20tool%2C%20it%E2%80%99s%20a%20tool%20everyone%20should%20have%20at%20least%20a%20basic%20understanding%20of.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGetting%20started%20with%20Git%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMy%20journey%20with%20Git%20began%20when%20I%20wanted%20to%20contribute%20to%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2F%3FWT.mc_id%3Ditopstalk-blog-salean%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EMicrosoft%20Docs%3C%2FA%3E.%26nbsp%3B%20Microsoft%20Docs%20is%20open%20sourced%2C%20meaning%20anyone%20can%20contribute%20to%20them%20and%20Github%20is%20used%20to%20store%20the%20documentation%20and%20act%20as%20the%20source%20control%20tool.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%2C%20let%E2%80%99s%20look%20at%20how%20you%20can%20start%20using%20Git%20and%20start%20your%20journey%20to%20contributing%20to%20Microsoft%20Docs%20and%20other%20open%20source%20projects.%20%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EInstall%20Git%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20first%20thing%20you%20need%20to%20do%20is%20install%20Git%20onto%20your%20machine.%20%26nbsp%3BDepending%20on%20what%20operating%20system%20you%20are%20using%20there%20are%20different%20installation%20methods%2C%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fazure%2Fdevops%2Flearn%2Fgit%2Finstall-and-set-up-git%3FWT.mc_id%3Ditopstalk-blog-salean%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ethis%3C%2FA%3E%20guide%20can%20help%20you%20through%20the%20right%20method%20for%20your%20system.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EConfigure%20Git%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOnce%20you%20have%20Git%20installed%20you%20need%20to%20configure%20it.%26nbsp%3B%20You%20need%20to%20set%20your%20name%20and%20contact%20information%2C%20so%20that%20when%20you%20contribute%20to%20any%20project%20so%20others%20can%20identify%20that%20it%20was%20that%20made%20the%20change.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20do%20this%20by%20issuing%20to%20commands%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Egit%20config%20--global%20user.name%20%22Sarah%20Lean%22%0Agit%20config%20--global%20user.email%20sarah%40fabrikam.com%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EWork%20on%20a%20repository%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%E2%80%99m%20going%20to%20start%20work%20on%20a%20Github%20repository%2C%20but%20rather%20than%20do%20that%20on%20the%20Github%20website%20I%20want%20to%20have%20a%20copy%20on%20my%20machine%20to%20work%20on%20until%20I%20am%20happy%20to%20share%20my%20work.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20pull%20down%20a%20copy%20of%20the%20repository%20to%20my%20machine%2C%20I%20open%20up%20a%20internet%20browser%20and%20find%20the%20repository%20and%20copy%20the%20URL.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%20open%20up%20my%20Git%20session%20and%20issue%20the%20command%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Egit%20clone%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fweeyin83%2FLearningGit%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fweeyin83%2FLearningGit%3C%2FA%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20now%20want%20to%20change%20directory%20and%20start%20to%20work%20with%20that%20repository%20and%20it%E2%80%99s%20files.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Ecd%20LearningGit%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20916px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F136654i4FFB217EA9D4A349%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22git-pic1.png%22%20title%3D%22git-pic1.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EBash%20screen%20with%20commands%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENow%20my%20repository%20is%20empty%20so%20I%20want%20to%20create%20a%20Readme%20file%20that%20will%20help%20people%20understand%20the%20purpose%20of%20my%20repository.%20%26nbsp%3BThe%20readme%20will%20act%20as%20documentation%20for%20the%20repository%20and%20help%20people%20understand%20why%20I%E2%80%99ve%20created%20and%20how%20to%20use%20it.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EI%E2%80%99m%20going%20to%20still%20to%20creating%20and%20editing%20my%20file%20within%20the%20Git%20console%2C%20to%20show%20you%20the%20full%20power%20of%20Git%20but%20there%20are%20other%20methods%20of%20creating%20and%20modifying%20files%2C%20via%20tools%20such%20as%20%3CA%20href%3D%22https%3A%2F%2Fcode.visualstudio.com%2F%3FWT.mc_id%3Ditopstalk-blog-salean%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EVisual%20Studio%20Code%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%2C%20within%20my%20Git%20session%2C%20I%20will%20issue%20the%20command%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Ecat%20%26gt%3B%20readme.md%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20creates%20my%20new%20file%20and%20then%20allows%20me%20to%20add%20in%20some%20input.%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorclipboard_image_2%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3EOnce%20I%E2%80%99ve%20entered%20the%20file%20contents%20I%20want%20I%20use%20Ctrl%2BD%20to%20exit%20and%20the%20file%20is%20created%20and%20saved.%3C%2FP%3E%0A%3CP%3ENow%20I%20want%20to%20share%20this%20file%20with%20the%20rest%20of%20my%20team.%26nbsp%3B%20To%20do%20that%20I%20need%20to%20do%20to%20three%20things%2C%20add%20the%20content%20to%20the%20repository%20index%2C%20commit%20my%20change%20to%20the%20repository%20and%20lastly%20take%20the%20changes%20I%E2%80%99ve%20made%20on%20my%20machine%20and%20add%20them%20to%20the%20repository%20back%20on%20Github.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESo%20my%20first%20command%20in%20the%20Git%20session%20is%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Egit%20add%20readme.md%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EMy%20new%20file%20is%20now%20indexed%20and%20ready%20to%20be%20committed%20to%20my%20repository.%20My%20next%20command%20is%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Egit%20commit%20-m%20%E2%80%9CAdd%20in%20readme%E2%80%9D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20commit%20command%20records%20the%20changes%20I%E2%80%99ve%20made%20and%20using%20the%20%3CSTRONG%3E-m%3C%2FSTRONG%3E%20switch%20I%20give%20a%20brief%20description%20of%20what%20I%E2%80%99ve%20done%2C%20again%20this%20is%20best%20practice%20so%20people%20understand%20the%20changes%20that%20have%20been%20made.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAnd%20the%20last%20command%20I%20issue%20is%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3Egit%20push%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20push%20command%20takes%20the%20files%20and%20changes%20you%E2%80%99ve%20made%20on%20your%20local%20machine%20and%20puts%20them%20back%20into%20Github.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20980px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F136656i2AB4541C280CF45C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22git-pic3.png%22%20title%3D%22git-pic3.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EBash%20screen%20with%20commands%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EWhen%20you%20visit%20Github%2C%20you%20should%20now%20see%20the%20changes%20you%E2%80%99ve%20just%20committed%20and%20push%20to%20your%20repository.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F136658i99798A3210C9E397%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22git-pic4.png%22%20title%3D%22git-pic4.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3Escreenshot%20of%20website%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20you%20can%20hopefully%20see%20using%20Git%20can%20be%20straightforward.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGit%20commands%20I%20use%20most%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3E%3CSTRONG%3Egit%20add%20.%3C%2FSTRONG%3E%3C%2FEM%3E%20%E2%80%93%20rather%20than%20specifying%20the%20individual%20files%20I%20want%20to%20update%20I%20this%20command%20which%20adds%20all%20the%20files%20I%E2%80%99ve%20added%2C%20deleted%20or%20modified%20to%20the%20index%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3E%3CSTRONG%3Egit%20commit%20-m%20%E2%80%9Cmaking%20changes%E2%80%9D%3C%2FSTRONG%3E%3C%2FEM%3E%20%E2%80%93%20this%20is%20committing%20my%20changes%20to%20the%20repository%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3E%3CSTRONG%3Egit%20push%3C%2FSTRONG%3E%20%3C%2FEM%3E%E2%80%93%20pushing%20my%20changes%20from%20my%20local%20machine%20to%20where%20the%20central%20copy%20of%20the%20repository%20is%20being%20stored%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3E%3CSTRONG%3Egit%20pull%3C%2FSTRONG%3E%3C%2FEM%3E%20%E2%80%93%20updating%20my%20local%20machine%20with%20changes%20from%20the%20central%20copy%20of%20the%20repository%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3E%3CSTRONG%3Egit%20clone%3C%2FSTRONG%3E%3C%2FEM%3E%20%E2%80%93%20pulling%20the%20initial%20copy%20of%20a%20repository%20down%20to%20work%20on%20my%20local%20machine%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3E%3CSTRONG%3Egit%20gc%3C%2FSTRONG%3E%3C%2FEM%3E%20%E2%80%93%20this%20is%20the%20garbage%20collection%20command%2C%20it%20runs%20some%20housekeeping%20on%20the%20repository%20such%20as%20compressing%20file%20review%20or%20removing%20unreachable%20objects%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGetting%20involved%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAs%20I%20mentioned%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2F%3FWT.mc_id%3Ditopstalk-blog-salean%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3EMicrosoft%20Docs%3C%2FA%3E%20are%20open%20source%2C%20so%20anyone%20can%20contribute%20to%20the%20betterment%20of%20them%2C%20and%20this%20was%20where%20I%20started.%20%26nbsp%3BBy%20seeing%20some%20incorrect%20documentation%20and%20correcting%20it.%3C%2FP%3E%0A%3CP%3EIt%E2%80%99s%20also%20worth%20mentioning%20that%20as%20we%20are%20in%20October%2C%20this%20year%E2%80%99s%20current%20%3CA%20href%3D%22https%3A%2F%2Fhacktoberfest.digitalocean.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3EHacktoberfest%3C%2FA%3E%20is%20in%20full%20swing.%20This%20is%20a%20community%20event%20where%20people%20are%20encouraged%20to%20contribute%20to%20open%20source%20projects%20and%20in%20return%20can%20get%20some%20awesome%20swag.%26nbsp%3B%20You%20just%20need%20to%20register%20and%20contribute%20to%20four%20open%20source%20projects%20and%20that%20swag%20can%20be%20yours!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EGo%20out%20and%20start%20your%20Git%20journey%20today!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-905676%22%20slang%3D%22en-US%22%3E%3CP%3EGit%20is%20something%20I%20thought%20was%20only%20useful%20for%20developers%2C%20however%20several%20years%20ago%20I%20found%20out%20how%20to%20utilize%20it%20as%20an%20IT%20Pro.%26nbsp%3B%20In%20this%20blog%20post%20I%20cover%20off%20why%20I%20got%20started%2C%20how%20you%20can%20get%20started%20and%20some%20useful%20commands.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F137479iA8A18D2C2644CEF9%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22gitteaser.png%22%20title%3D%22gitteaser.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EBash%20terminal%20and%20Git%20logo%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-905676%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Egit%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Egithub%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ESarah%20Lean%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft

@Thomas Rayner shared his six Git commands for beginners in a blog post, in this post I share my journey of learning Git, the commands I use and how you get involved further. 

 

It’s one of those tools, products that I always resigned to being within the developer toolbox and not something an IT Pro would ever consider using.  But over the last three years, it’s become one of those tools I keep installed on my machine and one I now use on a weekly basis.

 

What is Git

 

Git is an open source project, that has become the de facto standard tool for helping end users/organisations with their version control.   It can run on a range of operating systems and there is a large community behind it with lots of documentation and tutorial available.

 

Learning Git

 

Now Git is hard to learn.  I think that’s a widely known or accepted fact, and I can vouch for it.  I only know a sub section of its functionality and tricks.  I probably do things in the less effective method possible, but I have learnt how to use it, and as I say it’s become something I use at least once a week.

 

Why learn Git?

 

As I said earlier it’s become a de facto standard, for hobbyists to enterprises.  Regardless of where your source code is stored, Git can help you manage it.  And it’s not just a developer tool, it’s a tool everyone should have at least a basic understanding of.

 

Getting started with Git

 

My journey with Git began when I wanted to contribute to Microsoft Docs.  Microsoft Docs is open sourced, meaning anyone can contribute to them and Github is used to store the documentation and act as the source control tool.

 

So, let’s look at how you can start using Git and start your journey to contributing to Microsoft Docs and other open source projects.  

 

Install Git

 

The first thing you need to do is install Git onto your machine.  Depending on what operating system you are using there are different installation methods, this guide can help you through the right method for your system.

 

Configure Git

 

Once you have Git installed you need to configure it.  You need to set your name and contact information, so that when you contribute to any project so others can identify that it was that made the change.

 

You do this by issuing to commands:

 

git config --global user.name "Sarah Lean"
git config --global user.email sarah@fabrikam.com

 

Work on a repository

 

I’m going to start work on a Github repository, but rather than do that on the Github website I want to have a copy on my machine to work on until I am happy to share my work. 

 

To pull down a copy of the repository to my machine, I open up a internet browser and find the repository and copy the URL.

 

I open up my Git session and issue the command:

 

git clone https://github.com/weeyin83/LearningGit

 

You now want to change directory and start to work with that repository and it’s files.

 

cd LearningGit

 

git-pic1.pngBash screen with commands

 

Now my repository is empty so I want to create a Readme file that will help people understand the purpose of my repository.  The readme will act as documentation for the repository and help people understand why I’ve created and how to use it.

 

I’m going to still to creating and editing my file within the Git console, to show you the full power of Git but there are other methods of creating and modifying files, via tools such as Visual Studio Code.

 

So, within my Git session, I will issue the command:

 

cat > readme.md

 

This creates my new file and then allows me to add in some input.

 

Once I’ve entered the file contents I want I use Ctrl+D to exit and the file is created and saved.

Now I want to share this file with the rest of my team.  To do that I need to do to three things, add the content to the repository index, commit my change to the repository and lastly take the changes I’ve made on my machine and add them to the repository back on Github.

 

So my first command in the Git session is:

 

git add readme.md

 

My new file is now indexed and ready to be committed to my repository. My next command is:

 

git commit -m “Add in readme”

 

The commit command records the changes I’ve made and using the -m switch I give a brief description of what I’ve done, again this is best practice so people understand the changes that have been made.

 

And the last command I issue is:

 

git push

 

The push command takes the files and changes you’ve made on your local machine and puts them back into Github.

git-pic3.pngBash screen with commands

When you visit Github, you should now see the changes you’ve just committed and push to your repository.

git-pic4.pngscreenshot of website

 

As you can hopefully see using Git can be straightforward.

 

Git commands I use most

 

git add . – rather than specifying the individual files I want to update I this command which adds all the files I’ve added, deleted or modified to the index

 

git commit -m “making changes” – this is committing my changes to the repository

 

git push – pushing my changes from my local machine to where the central copy of the repository is being stored

 

git pull – updating my local machine with changes from the central copy of the repository

 

git clone – pulling the initial copy of a repository down to work on my local machine

 

git gc – this is the garbage collection command, it runs some housekeeping on the repository such as compressing file review or removing unreachable objects

 

Getting involved

 

As I mentioned the Microsoft Docs are open source, so anyone can contribute to the betterment of them, and this was where I started.  By seeing some incorrect documentation and correcting it.

It’s also worth mentioning that as we are in October, this year’s current Hacktoberfest is in full swing. This is a community event where people are encouraged to contribute to open source projects and in return can get some awesome swag.  You just need to register and contribute to four open source projects and that swag can be yours!

 

Go out and start your Git journey today!