SlideShare une entreprise Scribd logo
1  sur  23
Introduction to Git and Github




                  Dade’ Aderemi
         http://geekabyte.blogspot.com
What is Git and Github

 git
 Git is an extremely fast, efficient, distributed version control
 system used for collaborative development of software. Git
 was designed and developed by Linus Torvalds.

 git·hub
 Github is a web-based hosting service for software
 development projects that use the Git revision control
 system. Github was founded by chris wanstrath and tom
 preston-werner and PJ Hyett.
Flow

Installing
Configuring Git with Github
Working locally with Github
Working remotely with Github
Installing Git


   Installing Git is simple.
   Download and follow the steps of installation.
   Find detailed installations:

                                Linux
              http://help.github.com/linux-set-up-git/
                              Windows
               http://help.github.com/win-set-up-git/
                                 OSX
              http://help.github.com/mac-set-up-git/
Configuring Git with GitHUB


 Github makes using Git a lot cooler.

 Steps to have your Git installed to work with Github is as follows:
 1. Generate SSH Key
 2. Add SSH Key to Github
 3. Setting up preference and info
 4. Testing
Configuring Git with GitHUB

 Generate SSH Key
   To generate a new SSH key, enter the code below. Press Enter to
   go with the default settings.




   Now you need to enter a passphrase.
Configuring Git with GitHUB

Passphrase is another layer that makes you SSH key more secure. You
should see something like this. And a id_rsa.pub file would be created in
your working directory.
Configuring Git with GitHUB

 Add SSH Key To Github
   Create an account on www.github.com. Login, go to “Account
   Settings” > Click “SSH Keys” > Click “Add another public key”



   Open the id_rsa.pub file with a text editor. copy your SSH key exactly
   as it is written without adding any newlines or whitespace. Now paste
   it into the “Key” field. Leave the title out. Click Add Key and that is
   all.
Configuring Git with GitHUB

 Setting Up Info
    Git tracks who makes each commit by checking the user’s name and email.
    To set these, enter the code below, replacing the name and email with your
    own. The name should be your actual name, not your GitHub username.




   More options include
   git config --global color.branch auto
   git config --global color.diff auto
   Find more customization options here:
   http://book.git-scm.com/5_customizing_git.html
Configuring Git with GitHUB

 Testing setup
 To make sure everything is working type the following code.


 You should get




 Type Yes and you are done!
Working with Git Locally


 Creating Projects
   Navigate into the directory you want to create project in and run
   this command



 $ git init
Working with Git Locally


 Adding Files to Staging Area
   In Git, you have to add file contents to your staging area before
   you can commit them

   $ git add .
   (add all files recursively)

      $ git add *
   (add all files)
Working with Git Locally


 Checking Status of project
   See what the status of your staging area is compared to the code in
   your working directory, you can run the git status command




   $ git status
   $ git status –s                                  (non-verbose)
Working with Git Locally

 Committing Changes
   Run this command to actually record snapshot that has been
   added.
   Git records your name and email address with every commit you
   make.

$ git commit -m ‘first commit‘
   Every commit should be accompanied by a message which
   describes what the commit is about. You specify this with ‘-m’
   flag.
Working with Git Locally

 Branch Command
   The git branch command is a general branch management tool
   for Git. A git branch is basically the context in which you
   currently work. To create a new branch run

   $ git branch [branchname]
   (creates a branch)

   $ git branch
   (lists existing branch)

   When you run git init, a ‘master’ branch is
   automatically created.
Working remotely with Github


  So far, we have been working with Git on a local system. To put
  your project up on GitHub, you’ll need to have a GitHub
  repository for it to live in. Follow the following steps.

  Login into Github and click on New Repository
Working remotely with Github

  Proceed to fill the form to create a new repository.
Working remotely with Github


  Each Repository has a unique URL. This would be needed when
  you want to move your files to github. Go to the Repository
  page and you would find the URL as similar as below:
Working remotely with Github

 Adding a remote repository and alias
   If you want to share a locally created repository to github it is
   generally easiest to add it as a remote on your local machine. Git
   stores an alias or nickname for each remote repository URL So
   that you don't have to use the full URL of a remote repository
   every time you want to synchronize with it. To add a remote use
   the remote add command

   $ git remote add [alias] [url]
   alias = Name you want to refer to the remote eg origin, project
   etc
   url = unique url of the remote repository.

   Example git remote add origin git@github.com:dadepo/Padly.git
Working remotely with Github

 Copying a Git Repository with Clone
   If you need to collaborate with someone on a project, or if you
   want to get a copy of a project so you can look at or use the
   code, you will clone it. To do this run the following command:

 $ git clone [url]

 url = unique url of the remote repository.

 For example to clone a repository at
 git@github.com:dadepo/Padly.git you type

 git clone git@github.com:dadepo/Padly.git
Working remotely with Github

 Updating from a remote repository
   Git has two commands to update itself from a remote repository.


   git fetch
   git pull
   The difference in these two commands in the simplest terms is
   that, "git pull" does a "git fetch" followed by a "git
   merge".
Working remotely with Github


 Updating a remote repository
   To update a remote repository with changes you have made locally you
   run the following command


   git push [alias] [branch]
   * If someone else has pushed since you last fetched and merged, the Git server will
   deny your push until you are up to date.
More Resources on Git


http://help.github.com/
http://learn.github.com/p/intro.html
http://gitref.org/index.html

Contenu connexe

Tendances

Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsLee Hanxue
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with GitLuigi De Russis
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshareRakesh Sukumar
 
Workshop on Git and GitHub
Workshop on Git and GitHubWorkshop on Git and GitHub
Workshop on Git and GitHubDSCVSSUT
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to GitColin Su
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial IJim Yeh
 
Git hub ppt presentation
Git hub ppt presentationGit hub ppt presentation
Git hub ppt presentationAyanaRukasar
 
Introducing GitLab (September 2018)
Introducing GitLab (September 2018)Introducing GitLab (September 2018)
Introducing GitLab (September 2018)Noa Harel
 
Introduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionIntroduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionAnwarul Islam
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHubNicolás Tourné
 
Introduction to GitHub Actions
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub ActionsKnoldus Inc.
 

Tendances (20)

Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Version Control with Git
Version Control with GitVersion Control with Git
Version Control with Git
 
Introduction to github slideshare
Introduction to github slideshareIntroduction to github slideshare
Introduction to github slideshare
 
git and github
git and githubgit and github
git and github
 
Workshop on Git and GitHub
Workshop on Git and GitHubWorkshop on Git and GitHub
Workshop on Git and GitHub
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 
Git hub ppt presentation
Git hub ppt presentationGit hub ppt presentation
Git hub ppt presentation
 
Git training v10
Git training v10Git training v10
Git training v10
 
Introducing GitLab (September 2018)
Introducing GitLab (September 2018)Introducing GitLab (September 2018)
Introducing GitLab (September 2018)
 
GitHub Basics - Derek Bable
GitHub Basics - Derek BableGitHub Basics - Derek Bable
GitHub Basics - Derek Bable
 
Git and git flow
Git and git flowGit and git flow
Git and git flow
 
Git n git hub
Git n git hubGit n git hub
Git n git hub
 
Github
GithubGithub
Github
 
Introduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training SessionIntroduction to Gitlab | Gitlab 101 | Training Session
Introduction to Gitlab | Gitlab 101 | Training Session
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 
Git & GitHub WorkShop
Git & GitHub WorkShopGit & GitHub WorkShop
Git & GitHub WorkShop
 
Introduction to GitHub Actions
Introduction to GitHub ActionsIntroduction to GitHub Actions
Introduction to GitHub Actions
 
Git and github
Git and githubGit and github
Git and github
 

En vedette

AIESEC Nigeria Corporate Portfolio
AIESEC Nigeria Corporate PortfolioAIESEC Nigeria Corporate Portfolio
AIESEC Nigeria Corporate PortfolioAderemi Dadepo
 
Zend\Expressive - höher, schneller, weiter
Zend\Expressive - höher, schneller, weiterZend\Expressive - höher, schneller, weiter
Zend\Expressive - höher, schneller, weiterRalf Eggert
 
Creating an API with Expressive
Creating an API with ExpressiveCreating an API with Expressive
Creating an API with ExpressiveElton Minetto
 

En vedette (7)

AIESEC Nigeria Corporate Portfolio
AIESEC Nigeria Corporate PortfolioAIESEC Nigeria Corporate Portfolio
AIESEC Nigeria Corporate Portfolio
 
Tunesoflovepreview
TunesoflovepreviewTunesoflovepreview
Tunesoflovepreview
 
Love Creating!
Love Creating!Love Creating!
Love Creating!
 
Wordcampnigeria
WordcampnigeriaWordcampnigeria
Wordcampnigeria
 
Zend\Expressive - höher, schneller, weiter
Zend\Expressive - höher, schneller, weiterZend\Expressive - höher, schneller, weiter
Zend\Expressive - höher, schneller, weiter
 
Creating an API with Expressive
Creating an API with ExpressiveCreating an API with Expressive
Creating an API with Expressive
 
Theory Of Design
Theory Of DesignTheory Of Design
Theory Of Design
 

Similaire à Introduction to git and github

Similaire à Introduction to git and github (20)

introductiontogitandgithub-120702044048-phpapp01.pdf
introductiontogitandgithub-120702044048-phpapp01.pdfintroductiontogitandgithub-120702044048-phpapp01.pdf
introductiontogitandgithub-120702044048-phpapp01.pdf
 
GIT By Sivakrishna
GIT By SivakrishnaGIT By Sivakrishna
GIT By Sivakrishna
 
Github By Nyros Developer
Github By Nyros DeveloperGithub By Nyros Developer
Github By Nyros Developer
 
Git and Github.pptx
Git and Github.pptxGit and Github.pptx
Git and Github.pptx
 
Getting started With GIT
Getting started With GITGetting started With GIT
Getting started With GIT
 
Git presentation
Git presentationGit presentation
Git presentation
 
Intro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucketIntro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucket
 
Git & Github
Git & GithubGit & Github
Git & Github
 
Brief tutorial on Git
Brief tutorial on GitBrief tutorial on Git
Brief tutorial on Git
 
16 Git
16 Git16 Git
16 Git
 
Introduction to git and Github
Introduction to git and GithubIntroduction to git and Github
Introduction to git and Github
 
Beginner's guide to git and github
Beginner's guide to git and github Beginner's guide to git and github
Beginner's guide to git and github
 
DevOps Expt 2.pdf
DevOps Expt 2.pdfDevOps Expt 2.pdf
DevOps Expt 2.pdf
 
Extra bit with git
Extra bit with gitExtra bit with git
Extra bit with git
 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
 
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 & GitLab
Git & GitLabGit & GitLab
Git & GitLab
 
Day 2_ Get Git with It! A Developer's Workshop.pptx
Day 2_ Get Git with It! A Developer's Workshop.pptxDay 2_ Get Git with It! A Developer's Workshop.pptx
Day 2_ Get Git with It! A Developer's Workshop.pptx
 
Git github
Git githubGit github
Git github
 
14 oct Git & GitHub.pptx
14 oct Git & GitHub.pptx14 oct Git & GitHub.pptx
14 oct Git & GitHub.pptx
 

Dernier

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

Dernier (20)

Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

Introduction to git and github

  • 1. Introduction to Git and Github Dade’ Aderemi http://geekabyte.blogspot.com
  • 2. What is Git and Github git Git is an extremely fast, efficient, distributed version control system used for collaborative development of software. Git was designed and developed by Linus Torvalds. git·hub Github is a web-based hosting service for software development projects that use the Git revision control system. Github was founded by chris wanstrath and tom preston-werner and PJ Hyett.
  • 3. Flow Installing Configuring Git with Github Working locally with Github Working remotely with Github
  • 4. Installing Git Installing Git is simple. Download and follow the steps of installation. Find detailed installations: Linux http://help.github.com/linux-set-up-git/ Windows http://help.github.com/win-set-up-git/ OSX http://help.github.com/mac-set-up-git/
  • 5. Configuring Git with GitHUB Github makes using Git a lot cooler. Steps to have your Git installed to work with Github is as follows: 1. Generate SSH Key 2. Add SSH Key to Github 3. Setting up preference and info 4. Testing
  • 6. Configuring Git with GitHUB Generate SSH Key To generate a new SSH key, enter the code below. Press Enter to go with the default settings. Now you need to enter a passphrase.
  • 7. Configuring Git with GitHUB Passphrase is another layer that makes you SSH key more secure. You should see something like this. And a id_rsa.pub file would be created in your working directory.
  • 8. Configuring Git with GitHUB Add SSH Key To Github Create an account on www.github.com. Login, go to “Account Settings” > Click “SSH Keys” > Click “Add another public key” Open the id_rsa.pub file with a text editor. copy your SSH key exactly as it is written without adding any newlines or whitespace. Now paste it into the “Key” field. Leave the title out. Click Add Key and that is all.
  • 9. Configuring Git with GitHUB Setting Up Info Git tracks who makes each commit by checking the user’s name and email. To set these, enter the code below, replacing the name and email with your own. The name should be your actual name, not your GitHub username. More options include git config --global color.branch auto git config --global color.diff auto Find more customization options here: http://book.git-scm.com/5_customizing_git.html
  • 10. Configuring Git with GitHUB Testing setup To make sure everything is working type the following code. You should get Type Yes and you are done!
  • 11. Working with Git Locally Creating Projects Navigate into the directory you want to create project in and run this command $ git init
  • 12. Working with Git Locally Adding Files to Staging Area In Git, you have to add file contents to your staging area before you can commit them $ git add . (add all files recursively) $ git add * (add all files)
  • 13. Working with Git Locally Checking Status of project See what the status of your staging area is compared to the code in your working directory, you can run the git status command $ git status $ git status –s (non-verbose)
  • 14. Working with Git Locally Committing Changes Run this command to actually record snapshot that has been added. Git records your name and email address with every commit you make. $ git commit -m ‘first commit‘ Every commit should be accompanied by a message which describes what the commit is about. You specify this with ‘-m’ flag.
  • 15. Working with Git Locally Branch Command The git branch command is a general branch management tool for Git. A git branch is basically the context in which you currently work. To create a new branch run $ git branch [branchname] (creates a branch) $ git branch (lists existing branch) When you run git init, a ‘master’ branch is automatically created.
  • 16. Working remotely with Github So far, we have been working with Git on a local system. To put your project up on GitHub, you’ll need to have a GitHub repository for it to live in. Follow the following steps. Login into Github and click on New Repository
  • 17. Working remotely with Github Proceed to fill the form to create a new repository.
  • 18. Working remotely with Github Each Repository has a unique URL. This would be needed when you want to move your files to github. Go to the Repository page and you would find the URL as similar as below:
  • 19. Working remotely with Github Adding a remote repository and alias If you want to share a locally created repository to github it is generally easiest to add it as a remote on your local machine. Git stores an alias or nickname for each remote repository URL So that you don't have to use the full URL of a remote repository every time you want to synchronize with it. To add a remote use the remote add command $ git remote add [alias] [url] alias = Name you want to refer to the remote eg origin, project etc url = unique url of the remote repository. Example git remote add origin git@github.com:dadepo/Padly.git
  • 20. Working remotely with Github Copying a Git Repository with Clone If you need to collaborate with someone on a project, or if you want to get a copy of a project so you can look at or use the code, you will clone it. To do this run the following command: $ git clone [url] url = unique url of the remote repository. For example to clone a repository at git@github.com:dadepo/Padly.git you type git clone git@github.com:dadepo/Padly.git
  • 21. Working remotely with Github Updating from a remote repository Git has two commands to update itself from a remote repository. git fetch git pull The difference in these two commands in the simplest terms is that, "git pull" does a "git fetch" followed by a "git merge".
  • 22. Working remotely with Github Updating a remote repository To update a remote repository with changes you have made locally you run the following command git push [alias] [branch] * If someone else has pushed since you last fetched and merged, the Git server will deny your push until you are up to date.
  • 23. More Resources on Git http://help.github.com/ http://learn.github.com/p/intro.html http://gitref.org/index.html