SlideShare a Scribd company logo
1 of 30
@rebelwebdev
Git Basics
Effingham Software Developer Meetup
1
@rebelwebdev
Goal
To understand the basic commands of git, and how to integrate it into your
workflow.
2
@rebelwebdev
What is it
● Git is a tool to keep track of every change made to your code
● Git is a distributed source control (unlike TFVS which is centralized)
● Git itself is not a issue tracker, the tools build on top of git are issue trackers
(i.e. Github, Gitlab, TFS)
3
@rebelwebdev
Why?
● Git provides tools to make working in a team easier compared to working
without.
● Keep a history of changes
● Versioning (release points)
● Code Reviews
4
@rebelwebdev
Installing Git
● Windows
○ Installer Available at: https://git-scm.com/download/win
● Linux
○ Install using your favorite package manager
● Mac
○ Install using MacPorts, Homebrew, https://git-scm.com
● BSD
5
@rebelwebdev
Git Setup
● Windows will need extra setup for using Git over SSH
● Setup global config options
○ User Name
○ User E-Mail Address
○ Commit Message Editor
git config --global user.name “Ryan Condron”
git config --global user.email “rebelwebdevelopment@gmail.com”
git config --global core.editor vim
6
@rebelwebdev
Initialize Your Project
● Open command line and change to the root directory of your project.
● Run the initialize command
● Prepare for your first commit
cd /Users/ryan/code/project
git init
7
@rebelwebdev
Preparing For Your First Commit
● Check for secrets (i.e. API Keys, encryption keys, passwords, etc.)
● .gitignore - ignores files and directories that should not be changed
○ Starter Templates: https://github.com/github/gitignore
○ Should be in every project
● Add a README file (general overview of the project)
● Run git status to make sure files and directories that need to be ignored are
ignored (i.e. secrets)
git status
8
@rebelwebdev
Things To Add To Source Control (git)
● Code
● Documentation
● Database Schema
● Automated Tests
● Photoshop Files
9
@rebelwebdev
Things Not to Add To Source Control (git)
● Secrets - anything that could compromise the end product if revealed
○ Passwords
○ API Keys
○ Encryption Keys
● Log files
● SSH Keys
● Dependencies (Add documentation Instead)
10
@rebelwebdev
Your First Commit
● Add all files to be committed
● Commit Changes
git add --all
git commit -m “Initial Commit”
11
@rebelwebdev
Staging files
Before you can commit you will need to stage files you want to commit. This is
performed by using the add subcommand followed by the directory or filename
with the full path. If the ‘--all’ switch is used it will stage all changed and new
files.
git add docs/setup.md
git add --all
12
@rebelwebdev
Git Commit
This can be performed a couple different ways with the ‘-m’ switch which
commits with a basic message and without which will open the default editor to
edit the commit message, used for more detailed messages.
git commit -m “Initial Commit”
git commit
git status
13
@rebelwebdev
Commit with full editor
14
@rebelwebdev
Good vs Bad Commit Messages
Updated setup docs to include dependencies
Setup docs was missing what dependencies are
required for development. I added a section on
how to setup those dependencies and where to
download them from.
Changed setup doc
15
@rebelwebdev
Git History
Each time you make a commit there is a entry in your history. You can view your
commit history. Your history keeps track of changes you have made to your
project all the way back to the initial commit. You can view history in the web
interface of your remote or using git log.
Remember to work in small commits, to make your history meaningful
git log
16
@rebelwebdev
Removing files and history
● History will show removed code as well as added code.
● Keep in mind that when you remove a file, code, or that password you forgot
to ignore, IT WILL STILL BE IN HISTORY AND VISIBLE!!!
● I have a tool for you at the end, to help remove these from history.
17
@rebelwebdev
Setup a Remote to Track Changes
After committing you should set up a remote to manage changes.
Several options exist for hosting for little to no cost.
● https://github.com (free public repos, paid private repos)
● https://gitlab.com (free repos public & private, pay for premium features)
● https://www.visualstudio.com/team-services/ (free for small teams)
● https://bitbucket.com (free for small teams)
git remote add origin https://github.com/username/repo.git
18
@rebelwebdev
Pushing
Once your remote is setup you can push your local changes to it using the push
subcommand followed by the remote name (central repository) and branch.
git push origin master
19
@rebelwebdev
Pulling
Pulling allows you to bring changes down from the remote to your local machine.
Just like pushing you can pull from a remote to your local repository. It will pull
changes from the remote branch to the current working branch on your local
machine.
git pull origin master
20
@rebelwebdev
Branching
Branching allows you to make code changes in an isolated environment, so you
won’t affect your production code base. This allow you to push bug fixes without
deploying partially built new features or waiting until those features are
complete.
● Goal is to keep master (main branch) stable
● Make changes in branches and merges changes into master once complete.
● Freedom to experimentgit branch experiment
git checkout -b experiment
21
@rebelwebdev
Merging
So we made changes in a branch and are ready to put those changes in
production. We need to merge. Most of the time you will merge using your
remote repository’s web interface. The exception would be merge conflicts. To
merge using the command line interface you first checkout out the target branch
and use the merge subcommand and passing the name of the merging branch.
git checkout master
git merge experiment
22
@rebelwebdev
Merge Example using the UI
23
@rebelwebdev
Merge Conflicts
Merge conflicts are when the changes made in the merging branch conflict with
changes made in the target branch since the merging branch was created. In this
case you/your team will need to go through the conflicts and decide how to
move forward.
24
@rebelwebdev
Resolving Merge Conflicts
Most git hosting services will guide you through the process. You will have a list
of conflicts (sometimes there is more than one) and you will need to go to each
affected file and decide which branches version to keep, which to remove,
sometimes a mix between both.
If doing on a local machine my favorite tool is the merge-conflicts plugin for
Atom. It will give you a list and you pick and choose the changes you want or a
combination of both.
25
@rebelwebdev
Tagging
When you deploying to production you should generate a tag to show deploy
points in your code base. A tag is a name for a specific commit. This works
similar to git commit. It is recommend that your tags name are a semantic
version number.
git tag -a ‘0.0.1’ -m ‘First release’
git tag -a ‘0.0.1’
26
@rebelwebdev
Semantic Versioning
Semantic Versioning is a standardized way to version software. It is three set of
numbers separated by (.) - 5.4.0
● The first number is a major version (5)
○ Introduce major features or changes
● The second number is the minor version (4)
○ Introduce minor features or changes
● The third number is the patch number (0)
○ Big fixes
27
@rebelwebdev
Forking
Most remote servers allow you to fork or copy a repository to a new location with
a new name. The main use of this is when you want to work with a project that
isn’t yours and you want to make a change i.e. a bug fix or a new feature. You
can do a pull request to allow the forked repository to pull in your change.
28
@rebelwebdev
Challenge: Hacktoberfest
Typically Digital Ocean runs a program during the month of October, to commit
to open source software. Last year you had to open 4 pull/merge requests on
github, during the month of October. When you complete the mission you get
goodies, typically a T-Shirt and stickers.
My challenge to you, is to participate!
29
@rebelwebdev
Bonus: Git GUI Tools
If command line is not your cup of tea, there are a few gui clients to help you out
● https://www.gitkraken.com/pro (cost for commercial use)
● https://www.sourcetreeapp.com/ (free)
● Many editors have git tools built in!
30

More Related Content

What's hot

Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitColin Su
 
Git Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierGit Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierChristoph Matthies
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git聖文 鄭
 
Git and github fundamentals
Git and github fundamentalsGit and github fundamentals
Git and github fundamentalsRajKharvar
 
Git tech talk
Git tech talkGit tech talk
Git tech talkrazasayed
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHubVikram SV
 
Contributing to open source using Git
Contributing to open source using GitContributing to open source using Git
Contributing to open source using GitYan Vugenfirer
 
Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introductionrschwietzke
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflowsArthur Shvetsov
 
Git introduction for Beginners
Git introduction for BeginnersGit introduction for Beginners
Git introduction for BeginnersMortezaTaghaddomi
 
Git Introduction
Git IntroductionGit Introduction
Git IntroductionGareth Hall
 
Git intro hands on windows with msysgit
Git intro hands on windows with msysgitGit intro hands on windows with msysgit
Git intro hands on windows with msysgitGeshan Manandhar
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practiceMajid Hosseini
 
[Public] gerrit concepts and workflows
[Public] gerrit   concepts and workflows[Public] gerrit   concepts and workflows
[Public] gerrit concepts and workflowsYanbin Kong
 
Using GIT for Everyone
Using GIT for EveryoneUsing GIT for Everyone
Using GIT for EveryoneGLC Networks
 

What's hot (20)

Git 101
Git 101Git 101
Git 101
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easierGit Tricks — git utilities that make life git easier
Git Tricks — git utilities that make life git easier
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
 
Git and github fundamentals
Git and github fundamentalsGit and github fundamentals
Git and github fundamentals
 
Git tech talk
Git tech talkGit tech talk
Git tech talk
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Contributing to open source using Git
Contributing to open source using GitContributing to open source using Git
Contributing to open source using Git
 
Git - The Incomplete Introduction
Git - The Incomplete IntroductionGit - The Incomplete Introduction
Git - The Incomplete Introduction
 
Git and GitHub workflows
Git and GitHub workflowsGit and GitHub workflows
Git and GitHub workflows
 
Git introduction for Beginners
Git introduction for BeginnersGit introduction for Beginners
Git introduction for Beginners
 
Git & Github
Git & GithubGit & Github
Git & Github
 
Git Introduction
Git IntroductionGit Introduction
Git Introduction
 
Git intro hands on windows with msysgit
Git intro hands on windows with msysgitGit intro hands on windows with msysgit
Git intro hands on windows with msysgit
 
Git and git workflow best practice
Git and git workflow best practiceGit and git workflow best practice
Git and git workflow best practice
 
Git
GitGit
Git
 
[Public] gerrit concepts and workflows
[Public] gerrit   concepts and workflows[Public] gerrit   concepts and workflows
[Public] gerrit concepts and workflows
 
Mini git tutorial
Mini git tutorialMini git tutorial
Mini git tutorial
 
Git
GitGit
Git
 
Using GIT for Everyone
Using GIT for EveryoneUsing GIT for Everyone
Using GIT for Everyone
 

Similar to Git Basics: Understanding Basic Commands and Integrating into Your Workflow

BLUG 2012 Version Control for Notes Developers
BLUG 2012 Version Control for Notes DevelopersBLUG 2012 Version Control for Notes Developers
BLUG 2012 Version Control for Notes DevelopersMartin Jinoch
 
git github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxgit github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxAbelPhilipJoseph
 
Git Tutorial A Comprehensive Guide for Beginners.pdf
Git Tutorial A Comprehensive Guide for Beginners.pdfGit Tutorial A Comprehensive Guide for Beginners.pdf
Git Tutorial A Comprehensive Guide for Beginners.pdfuzair
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow Sebin Benjamin
 
Git_tutorial.pdf
Git_tutorial.pdfGit_tutorial.pdf
Git_tutorial.pdfAliaaTarek5
 
Git for work groups ironhack talk
Git for work groups ironhack talkGit for work groups ironhack talk
Git for work groups ironhack talkTiago Ameller
 
git-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfgit-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfmurad khan
 
Git for developers
Git for developersGit for developers
Git for developersHacen Dadda
 
Using Git with WordPress - Presented by Nigel Rodgers.
Using Git with WordPress - Presented by Nigel Rodgers.Using Git with WordPress - Presented by Nigel Rodgers.
Using Git with WordPress - Presented by Nigel Rodgers.WordCamp Harare
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?9 series
 
Presentation on Repository Control System
Presentation on Repository Control SystemPresentation on Repository Control System
Presentation on Repository Control SystemMd. Mujahid Islam
 
Using Git and BitBucket
Using Git and BitBucketUsing Git and BitBucket
Using Git and BitBucketMedhat Dawoud
 
Introduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech ArticleIntroduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech ArticlePRIYATHAMDARISI
 

Similar to Git Basics: Understanding Basic Commands and Integrating into Your Workflow (20)

BLUG 2012 Version Control for Notes Developers
BLUG 2012 Version Control for Notes DevelopersBLUG 2012 Version Control for Notes Developers
BLUG 2012 Version Control for Notes Developers
 
Git & GitLab
Git & GitLabGit & GitLab
Git & GitLab
 
git github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxgit github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptx
 
Git Tutorial A Comprehensive Guide for Beginners.pdf
Git Tutorial A Comprehensive Guide for Beginners.pdfGit Tutorial A Comprehensive Guide for Beginners.pdf
Git Tutorial A Comprehensive Guide for Beginners.pdf
 
Introducing Git and git flow
Introducing Git and git flow Introducing Git and git flow
Introducing Git and git flow
 
Git_tutorial.pdf
Git_tutorial.pdfGit_tutorial.pdf
Git_tutorial.pdf
 
Git for work groups ironhack talk
Git for work groups ironhack talkGit for work groups ironhack talk
Git for work groups ironhack talk
 
git-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdfgit-commands-cheat-sheet-infopediya-com.pdf
git-commands-cheat-sheet-infopediya-com.pdf
 
Git github
Git githubGit github
Git github
 
Git for developers
Git for developersGit for developers
Git for developers
 
Using Git with WordPress - Presented by Nigel Rodgers.
Using Git with WordPress - Presented by Nigel Rodgers.Using Git with WordPress - Presented by Nigel Rodgers.
Using Git with WordPress - Presented by Nigel Rodgers.
 
GIT_Overview.
GIT_Overview.GIT_Overview.
GIT_Overview.
 
Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?Git Commands Every Developer Should Know?
Git Commands Every Developer Should Know?
 
Mini-training: Let’s Git It!
Mini-training: Let’s Git It!Mini-training: Let’s Git It!
Mini-training: Let’s Git It!
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
 
Git hub
Git hubGit hub
Git hub
 
Gn unify git
Gn unify gitGn unify git
Gn unify git
 
Presentation on Repository Control System
Presentation on Repository Control SystemPresentation on Repository Control System
Presentation on Repository Control System
 
Using Git and BitBucket
Using Git and BitBucketUsing Git and BitBucket
Using Git and BitBucket
 
Introduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech ArticleIntroduction to GitHub, Open Source and Tech Article
Introduction to GitHub, Open Source and Tech Article
 

Recently uploaded

chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 

Recently uploaded (20)

chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 

Git Basics: Understanding Basic Commands and Integrating into Your Workflow

  • 2. @rebelwebdev Goal To understand the basic commands of git, and how to integrate it into your workflow. 2
  • 3. @rebelwebdev What is it ● Git is a tool to keep track of every change made to your code ● Git is a distributed source control (unlike TFVS which is centralized) ● Git itself is not a issue tracker, the tools build on top of git are issue trackers (i.e. Github, Gitlab, TFS) 3
  • 4. @rebelwebdev Why? ● Git provides tools to make working in a team easier compared to working without. ● Keep a history of changes ● Versioning (release points) ● Code Reviews 4
  • 5. @rebelwebdev Installing Git ● Windows ○ Installer Available at: https://git-scm.com/download/win ● Linux ○ Install using your favorite package manager ● Mac ○ Install using MacPorts, Homebrew, https://git-scm.com ● BSD 5
  • 6. @rebelwebdev Git Setup ● Windows will need extra setup for using Git over SSH ● Setup global config options ○ User Name ○ User E-Mail Address ○ Commit Message Editor git config --global user.name “Ryan Condron” git config --global user.email “rebelwebdevelopment@gmail.com” git config --global core.editor vim 6
  • 7. @rebelwebdev Initialize Your Project ● Open command line and change to the root directory of your project. ● Run the initialize command ● Prepare for your first commit cd /Users/ryan/code/project git init 7
  • 8. @rebelwebdev Preparing For Your First Commit ● Check for secrets (i.e. API Keys, encryption keys, passwords, etc.) ● .gitignore - ignores files and directories that should not be changed ○ Starter Templates: https://github.com/github/gitignore ○ Should be in every project ● Add a README file (general overview of the project) ● Run git status to make sure files and directories that need to be ignored are ignored (i.e. secrets) git status 8
  • 9. @rebelwebdev Things To Add To Source Control (git) ● Code ● Documentation ● Database Schema ● Automated Tests ● Photoshop Files 9
  • 10. @rebelwebdev Things Not to Add To Source Control (git) ● Secrets - anything that could compromise the end product if revealed ○ Passwords ○ API Keys ○ Encryption Keys ● Log files ● SSH Keys ● Dependencies (Add documentation Instead) 10
  • 11. @rebelwebdev Your First Commit ● Add all files to be committed ● Commit Changes git add --all git commit -m “Initial Commit” 11
  • 12. @rebelwebdev Staging files Before you can commit you will need to stage files you want to commit. This is performed by using the add subcommand followed by the directory or filename with the full path. If the ‘--all’ switch is used it will stage all changed and new files. git add docs/setup.md git add --all 12
  • 13. @rebelwebdev Git Commit This can be performed a couple different ways with the ‘-m’ switch which commits with a basic message and without which will open the default editor to edit the commit message, used for more detailed messages. git commit -m “Initial Commit” git commit git status 13
  • 15. @rebelwebdev Good vs Bad Commit Messages Updated setup docs to include dependencies Setup docs was missing what dependencies are required for development. I added a section on how to setup those dependencies and where to download them from. Changed setup doc 15
  • 16. @rebelwebdev Git History Each time you make a commit there is a entry in your history. You can view your commit history. Your history keeps track of changes you have made to your project all the way back to the initial commit. You can view history in the web interface of your remote or using git log. Remember to work in small commits, to make your history meaningful git log 16
  • 17. @rebelwebdev Removing files and history ● History will show removed code as well as added code. ● Keep in mind that when you remove a file, code, or that password you forgot to ignore, IT WILL STILL BE IN HISTORY AND VISIBLE!!! ● I have a tool for you at the end, to help remove these from history. 17
  • 18. @rebelwebdev Setup a Remote to Track Changes After committing you should set up a remote to manage changes. Several options exist for hosting for little to no cost. ● https://github.com (free public repos, paid private repos) ● https://gitlab.com (free repos public & private, pay for premium features) ● https://www.visualstudio.com/team-services/ (free for small teams) ● https://bitbucket.com (free for small teams) git remote add origin https://github.com/username/repo.git 18
  • 19. @rebelwebdev Pushing Once your remote is setup you can push your local changes to it using the push subcommand followed by the remote name (central repository) and branch. git push origin master 19
  • 20. @rebelwebdev Pulling Pulling allows you to bring changes down from the remote to your local machine. Just like pushing you can pull from a remote to your local repository. It will pull changes from the remote branch to the current working branch on your local machine. git pull origin master 20
  • 21. @rebelwebdev Branching Branching allows you to make code changes in an isolated environment, so you won’t affect your production code base. This allow you to push bug fixes without deploying partially built new features or waiting until those features are complete. ● Goal is to keep master (main branch) stable ● Make changes in branches and merges changes into master once complete. ● Freedom to experimentgit branch experiment git checkout -b experiment 21
  • 22. @rebelwebdev Merging So we made changes in a branch and are ready to put those changes in production. We need to merge. Most of the time you will merge using your remote repository’s web interface. The exception would be merge conflicts. To merge using the command line interface you first checkout out the target branch and use the merge subcommand and passing the name of the merging branch. git checkout master git merge experiment 22
  • 24. @rebelwebdev Merge Conflicts Merge conflicts are when the changes made in the merging branch conflict with changes made in the target branch since the merging branch was created. In this case you/your team will need to go through the conflicts and decide how to move forward. 24
  • 25. @rebelwebdev Resolving Merge Conflicts Most git hosting services will guide you through the process. You will have a list of conflicts (sometimes there is more than one) and you will need to go to each affected file and decide which branches version to keep, which to remove, sometimes a mix between both. If doing on a local machine my favorite tool is the merge-conflicts plugin for Atom. It will give you a list and you pick and choose the changes you want or a combination of both. 25
  • 26. @rebelwebdev Tagging When you deploying to production you should generate a tag to show deploy points in your code base. A tag is a name for a specific commit. This works similar to git commit. It is recommend that your tags name are a semantic version number. git tag -a ‘0.0.1’ -m ‘First release’ git tag -a ‘0.0.1’ 26
  • 27. @rebelwebdev Semantic Versioning Semantic Versioning is a standardized way to version software. It is three set of numbers separated by (.) - 5.4.0 ● The first number is a major version (5) ○ Introduce major features or changes ● The second number is the minor version (4) ○ Introduce minor features or changes ● The third number is the patch number (0) ○ Big fixes 27
  • 28. @rebelwebdev Forking Most remote servers allow you to fork or copy a repository to a new location with a new name. The main use of this is when you want to work with a project that isn’t yours and you want to make a change i.e. a bug fix or a new feature. You can do a pull request to allow the forked repository to pull in your change. 28
  • 29. @rebelwebdev Challenge: Hacktoberfest Typically Digital Ocean runs a program during the month of October, to commit to open source software. Last year you had to open 4 pull/merge requests on github, during the month of October. When you complete the mission you get goodies, typically a T-Shirt and stickers. My challenge to you, is to participate! 29
  • 30. @rebelwebdev Bonus: Git GUI Tools If command line is not your cup of tea, there are a few gui clients to help you out ● https://www.gitkraken.com/pro (cost for commercial use) ● https://www.sourcetreeapp.com/ (free) ● Many editors have git tools built in! 30

Editor's Notes

  1. Welcome Discussing Git Basics
  2. Goal is to be able to use the core concepts and commands to use git for source control.
  3. Distributed No Central Repository (meaning no true master copy) Ability to work without a connection to a central repo Great working behind firewalls or without internet connection Elaborate on TFVS distributed.
  4. Available on most platforms Integrated into most IDE’s (Visual Studio, Atom, etc.)
  5. The --global sets the default for all projects, if it is removed it will only apply to the project of your current working directory Windows make sure you add git to your PATH for the command will not be available in cmd and setup .ssh folder inside your user directory
  6. Will generate a .git folder at the root of your project for meta data.
  7. Think about your folder structure, you may need a parent folder containing a folder with code and a folder with documentation/configuration. I.e. static websites
  8. There are certain things you want to add to source control or git, but not everything
  9. AWS API Keys in Github (cost users $1000’s) One exception with dependencies is working with legacy code bases and dependencies are hard to find. Remember depending on your repository settings you code may searchable.
  10. This will be the starting point to your repository. I.e. the beginning of time
  11. Note that if changes to a file after the add subcommand, the command will need ran again to include those changes.
  12. You should work in small commits. Empty directories will not be committed, to keep the directory structure in git, simple add a .keep or .gitkeep (empty file) to the directory
  13. Describe your changes, don’t be afraid to explain yourself. Other developers love when you drop context about the code you changed in the commit body
  14. For there to be information in the log you need to make commits more often and have good commit messages.
  15. Remote hosting services often come with an application to handle some git functions and track issues The best remote will depend on your setup.
  16. Origin is the name of the remote Master is the name of the branch
  17. Experiment without breaking production Master typically is the holy grail and should be kept stable. Protected Branches
  18. Example using gitlab
  19. Plan to have a future presentation on tips and tricks handling merge conflicts.
  20. Input release notes in tag body to help keep track of history Tags are typically done after a merge or a new feature is added to the code base.
  21. If you are working on a library that is used my multiple projects, you shouldn’t introduce new features on a patch release.
  22. Essentially a clone and push
  23. Show website
  24. While we discussed using basic of git from the command line, gui tools are available.