SlideShare une entreprise Scribd logo
1  sur  23
Télécharger pour lire hors ligne
Introduction to Git and Github
Dade’ Aderemi
http://geekabyte.blogspot.com
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.
What is Git and Github
Installing
Configuring Git with Github
Working locally with Github
Working remotely with Github
Flow
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/
Installing Git
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!
Configuring Git with GitHUB
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.
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
$ git commit -m ‘first commit‘
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 with Git Locally
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.
Working remotely with Github
http://help.github.com/
http://learn.github.com/p/intro.html
http://gitref.org/index.html
More Resources on Git

Contenu connexe

Similaire à introductiontogitandgithub-120702044048-phpapp01.pdf

Introduction to git and Github
Introduction to git and GithubIntroduction to git and Github
Introduction to git and GithubWycliff1
 
Git Developer Cheatsheet
Git Developer CheatsheetGit Developer Cheatsheet
Git Developer CheatsheetAbdul Basit
 
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
 
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 SahilSonar4
 
Git 101 Workshop
Git 101 WorkshopGit 101 Workshop
Git 101 WorkshopJoy Seng
 
Git, github and the hacktober fest
Git, github and the hacktober festGit, github and the hacktober fest
Git, github and the hacktober festUtkarshRaj83
 
Using Git to Organize Your Project
Using Git to Organize Your ProjectUsing Git to Organize Your Project
Using Git to Organize Your ProjectManish Suwal 'Enwil'
 
Github - Le Wagon Melbourne
Github - Le Wagon MelbourneGithub - Le Wagon Melbourne
Github - Le Wagon MelbournePaal Ringstad
 
Git & Github Workshop - Le Wagon Melbourne
Git & Github Workshop - Le Wagon MelbourneGit & Github Workshop - Le Wagon Melbourne
Git & Github Workshop - Le Wagon MelbournePaal Ringstad
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubDSC GVP
 

Similaire à introductiontogitandgithub-120702044048-phpapp01.pdf (20)

Introduction to git and Github
Introduction to git and GithubIntroduction to git and Github
Introduction to git and Github
 
Git & Github
Git & GithubGit & Github
Git & Github
 
16 Git
16 Git16 Git
16 Git
 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
 
DevOps Expt 2.pdf
DevOps Expt 2.pdfDevOps Expt 2.pdf
DevOps Expt 2.pdf
 
Git Developer Cheatsheet
Git Developer CheatsheetGit Developer Cheatsheet
Git Developer Cheatsheet
 
Git & GitLab
Git & GitLabGit & GitLab
Git & GitLab
 
14 oct Git & GitHub.pptx
14 oct Git & GitHub.pptx14 oct Git & GitHub.pptx
14 oct Git & GitHub.pptx
 
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
 
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
 
Git 101 Workshop
Git 101 WorkshopGit 101 Workshop
Git 101 Workshop
 
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 and the hacktober fest
Git, github and the hacktober festGit, github and the hacktober fest
Git, github and the hacktober fest
 
Using Git to Organize Your Project
Using Git to Organize Your ProjectUsing Git to Organize Your Project
Using Git to Organize Your Project
 
Extra bit with git
Extra bit with gitExtra bit with git
Extra bit with git
 
Git hub visualstudiocode
Git hub visualstudiocodeGit hub visualstudiocode
Git hub visualstudiocode
 
Github - Le Wagon Melbourne
Github - Le Wagon MelbourneGithub - Le Wagon Melbourne
Github - Le Wagon Melbourne
 
Git & Github Workshop - Le Wagon Melbourne
Git & Github Workshop - Le Wagon MelbourneGit & Github Workshop - Le Wagon Melbourne
Git & Github Workshop - Le Wagon Melbourne
 
Hacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHubHacktoberfest intro to Git and GitHub
Hacktoberfest intro to Git and GitHub
 

Plus de BruceLee275640

fdocuments.in_introduction-to-ibatis.ppt
fdocuments.in_introduction-to-ibatis.pptfdocuments.in_introduction-to-ibatis.ppt
fdocuments.in_introduction-to-ibatis.pptBruceLee275640
 
springtraning-7024840-phpapp01.pdf
springtraning-7024840-phpapp01.pdfspringtraning-7024840-phpapp01.pdf
springtraning-7024840-phpapp01.pdfBruceLee275640
 
java150929145120-lva1-app6892 (2).pptx
java150929145120-lva1-app6892 (2).pptxjava150929145120-lva1-app6892 (2).pptx
java150929145120-lva1-app6892 (2).pptxBruceLee275640
 

Plus de BruceLee275640 (7)

Git_new.pptx
Git_new.pptxGit_new.pptx
Git_new.pptx
 
68837.ppt
68837.ppt68837.ppt
68837.ppt
 
fdocuments.in_introduction-to-ibatis.ppt
fdocuments.in_introduction-to-ibatis.pptfdocuments.in_introduction-to-ibatis.ppt
fdocuments.in_introduction-to-ibatis.ppt
 
Utility.ppt
Utility.pptUtility.ppt
Utility.ppt
 
springtraning-7024840-phpapp01.pdf
springtraning-7024840-phpapp01.pdfspringtraning-7024840-phpapp01.pdf
springtraning-7024840-phpapp01.pdf
 
java150929145120-lva1-app6892 (2).pptx
java150929145120-lva1-app6892 (2).pptxjava150929145120-lva1-app6892 (2).pptx
java150929145120-lva1-app6892 (2).pptx
 
life science.pptx
life science.pptxlife science.pptx
life science.pptx
 

Dernier

%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburgmasabamasaba
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsBert Jan Schrijver
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 

Dernier (20)

%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Generic or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisionsGeneric or specific? Making sensible software design decisions
Generic or specific? Making sensible software design decisions
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 

introductiontogitandgithub-120702044048-phpapp01.pdf

  • 1. Introduction to Git and Github Dade’ Aderemi http://geekabyte.blogspot.com
  • 2. 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. What is Git and Github
  • 3. Installing Configuring Git with Github Working locally with Github Working remotely with Github Flow
  • 4. 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/ Installing Git
  • 5. 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
  • 6. 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
  • 7. 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
  • 8. 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
  • 9. 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
  • 10. Testing setup To make sure everything is working type the following code. You should get Type Yes and you are done! Configuring Git with GitHUB
  • 11. Creating Projects Navigate into the directory you want to create project in and run this command $ git init Working with Git Locally
  • 12. 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
  • 13. 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
  • 14. 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. 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 $ git commit -m ‘first commit‘
  • 15. 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 with Git Locally
  • 16. 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
  • 17. Proceed to fill the form to create a new repository. Working remotely with Github
  • 18. 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
  • 19. 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
  • 20. 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
  • 21. 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
  • 22. 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. Working remotely with Github