SlideShare a Scribd company logo
1 of 51
Download to read offline
Git and BitBucket
                      Medhat Dawoud

        /med7atdawoud
        /med7atdawoud
9 February 2013
This workshop will include

                             Source Code Management Systems


                                  Web-Based Code Hosting


                           Popular open source projects using SCM


                                        Intro to Git


                                   Let’s try Git Commands


                     Bitbucket as a web code server and management tool

9 February 2013
Source Code Management System

• It’s a way that we use to store projects’ source
  code files in a tree of versions.

• With no deal, all those SCMs creators build them
  on the same rules and structure.

• A lot of popular open source projects source
  codes are collected together all over the world
  using SCM systems.
9 February 2013
SCM Systems Examples

Lots of this type of software was created like:




 9 February 2013
Web based Code Hosting

• We can use SCMS on our machine locally that
  manage the code for you and create versions.

• but you can also host your code on web, this
  solution make it very secure and no lose of
  data under any circumstances.



9 February 2013
Web based Code Hosting Examples
A lot of Web-Based Code Servers provide Free and paid services Like:




  9 February 2013
Popular projects that use web-based code Hosting
        and Source Code Management Systems




                            Source1: https://git.wiki.kernel.org/index.php/GitProjects
9 February 2013
                            Source2: https://github.com/popular/starred
Popular projects that use web-based code Hosting
        and Source Code Management Systems




                            Source1: https://git.wiki.kernel.org/index.php/GitProjects
9 February 2013
                            Source2: https://github.com/popular/starred
Popular projects that use web-based code Hosting
        and Source Code Management Systems




                            Source1: https://git.wiki.kernel.org/index.php/GitProjects
9 February 2013
                            Source2: https://github.com/popular/starred
Popular projects that use web-based code Hosting
        and Source Code Management Systems




                            Source1: https://git.wiki.kernel.org/index.php/GitProjects
9 February 2013
                            Source2: https://github.com/popular/starred
SCMS

• We approved before when we start that all SCMSs are built on
  the same structure without any deal between them.

• Those all are called Source Code Management Systems
  (SCMSs).

• Main task of any SCMS is to:
   Track changes to files.
   Repository / database of changes
   Working directory / current state


9 February 2013
SCMS Operations

We can sort operations that we can do
with any SCMS into 4 main categories:
       Bootstrap (init, checkout, switch branch)

       Modify (add, delete, rename, commit)

       Information (status, diff, log)

       Reference (tag, branch)


9 February 2013
Types of SCMS

There are 2 types of SCM systems:



 Centralized SCM

 Distributed SCM

9 February 2013
Centralized SCM




9 February 2013
Centralized SCM

o Examples: Subversion, CVS, etc.
o Everything goes to the server, commit changes to the
     sever, checkout the latest revision from the server.
o No direct exchange between developers
o Operations require server, there are some drawbacks:
       Single point of failure
       Bottleneck


9 February 2013
Decentralized SCM




9 February 2013
Decentralized SCM

o Examples: Git, Mercurial, Bazaar, etc.
o Each copy of repository is identical and self-sufficient
o No need for a central server, but one may choose to have one
o Developers may directly exchange change sets over Wi-Fi at a
  local coffee shop :D
o Workflow :
      – Clone
      – Pull / fetch
      – push


9 February 2013
Ok, Let’s Start that workshop now
• Yes, it was just an intro to the Source Code
  Management Mechanism and the Web-Based
  Code Servers.
• Now to start talking in our session, I packed Git as
  our SCM or VCS and BitBucket as a Web-based
  Code Server and management tool will be
  discussed later.


                  Are you   Ready?
9 February 2013
What is Git ?

 Decentralized or Destributed Source Code
       Management(SCMS).
 Superior branching and merging mechanism.
 Support various protection devices against
       corruption.
 Supported by various code servers.
9 February 2013
Git History
• 2002
       Linus uses BitKeeper to track Linux.
       And BK gets Better, and Linux scale better.
• April 6, 2005
       BitKeeper drops free license.
       Linus write his own SCM, Git.
• April 18, 2005
       Git can merge.
• June 16, 2006
       Git is officially used to track Linux.
• Feb 14, 2007
       Git 1.5.0 is released.
       Major usability efforts.

9 February 2013
“ Nothing is perfect. Git is just *closer* to
 perfect than any other SCM out there ”

 - Linus




9 February 2013
Git First use

• If you are using Git for the first time, you will need to
  download the server into your machine according to
  your operation system.
• Just go to: http://git-scm.com/downloads and choose
  the suitable download and install it.




9 February 2013
Git First use continue ..

• If you are using linux you will find a command that
  will install Git from terminal.

• For example if you are using Ubuntu you will write
  this command in you terminal:




9 February 2013
Git Command line

• Now you have installed Git on your machine and you
  can go to terminal or CMD according to you OS and
  write any command, for example:
       $ git –-version
  this command returned the version of Git you have
  installed, you should find the result as follow:




9 February 2013
Git Commands

• Ok, there is a general structure of the git
  command that all commands use as follow:
     $ git <options> command <options>


• Git includes approximately 137 commands.

• Actually we don’t use all of them every day, so
  I’ll review here the every day use commands
  and let you check others.
9 February 2013
Git Common commands
                                          Add
                                 status           rm




                          push                             mv




                   pull                                           branch




                  merge                                           checkout




                          log                             clone




                                  init           commit
                                          diff

9 February 2013
Git Help

• For any new command for you and need a brief
  documentation for it use this:
     $ git <command> -h


• When you need a complete help you should write
  the following command and it will open a web
  page locally with the full docs for this command:
  $ git <command> --help
  or
  $ git help <command>
9 February 2013
Git Bootstrap

• Open the project work space (directory) and
  run this command inside it:
             $ git init
     this will create .git directory

• This directory (.git) include all meta data
  about versions and commits, working trees,
  changes, all configurations, … .

9 February 2013
Git Staging
• Staging means specifying files that you will commit to
  the server.

• Additions:
      $ git add file      #This add a specific file
      $ git add .         #This add all changed files

• Removal:
      $ git rm file       #This removes a specific file

• Renames:
      $ git mv old new    #This renames a specific file
9 February 2013
.gitignore file

• You can create a .gitignore file in your project directory
  and add files or directories that you need not to add to
  the server, examples for unwanted files:
       Automatically generated code (e.g. R.java for Android)
       Settings folder of editors that is created automatically.
       If you are using any dependences on other libraries like in
        PHP you can add them to composer.json and ignore them.
       Or any other unwanted files.

• So when you use add all files, git will automatically
  ignore the list of files you have written in this file.

9 February 2013
Git Commit

• Commit means to apply changes of staged files or all files to
  the repository locally.

• Commit changes must provided by a message that you explain
  in what is the changes in your commit from the last version:
       $ git commit –m ”this is the message”

• The above command commit only the staged files but if you
  want to commit all files you should use this:
       $ git commit -a –m ”this is the message”

• This means that the commit command here in applied on
  your machine only ??? …. The answer is yes
9 February 2013
Git work flow from work to commit




9 February 2013
Git information

• You can use status:
         $ git status
     to shows :
             • Staged
             • Unstaged
             • Untracked


• You can use show:
         $ git show
     that shows the last commit information, changes,
     author, and date. It has some more configurations
     that customize the result.
9 February 2013
Git information

Git show additions:

       Just shows stats
                  $ git show –-stat


       Just shows name and status
                  $ git show -–name-status




9 February 2013
Git information

• To review the latest commits or even all commits on
  some repository we use log command as follow:
             $ git log
• But you can also limit it to review commits in a specific
  period or in some branch or last 5 for example:
             $ git log -5
     or
             $ git log -1 master@{yesterday}
     or
             $ git log --author=medhatdawoud


• There are lots of additions see in docs or help.
9 February 2013
References




                  Tags
                         Branches



9 February 2013
References

• References are used to point to commits.

       To get the local branches we use:
             $ git branch –l
       To get the remote branches we use:
             $ git branch –r


       And to get the local tags we use:
             $ git tag -l


9 February 2013
References

• Creating new branch to HEAD:
      $ git branch name
     new branch “name” on HEAD

• Creating new branch to a commit:
      $ git branch name commit
     new branch “name” on that commit


9 February 2013
References

• Switching to branch:
     $ git checkout name
• We have option of creating and switching in
  the same command:
     $ git checkout -b name
• If you are switching to a branch that has
  changes, the switching might gives error, then
  you should merge with switch:
     $ git checkout -m name
9 February 2013
Merging

• If your HEAD is referring to a branch and want
  to merge it to other branch, simply use the
  following command, assume we have A, B
  branches,
     $ git checkout A
     $ git merge B
     Assume that we have A, B, C branches and want to merge
     them all in one command.
     $ git checkout A
     $ git merge B C
9 February 2013
Cloning

• If you have a remote code server on some host
  and want to get that repository on local, you
  just want to write this:
     $ git clone <remote>


• This will create a directory to the current root,
  with the same name of the repository you are
  cloning.

9 February 2013
Let’s Play with



9 February 2013
What’s Next ?

• Git is already installed into some editors like
  eclipse, aptana, … Search for your editor
  installation.

• There is a good free book for git, I recommend
  it for you to be more efficient in using Git as a
  Source Code Management System, check it
  from this link: http://progit.org

9 February 2013
An other Easy and Fast Solution

• I’ll tell you about another easy solution for
  windows users, it’s a git client with great GUI that
  makes every thing for you, it’s TortoiseGit



• Simply go to this link, download and install:
             http://code.google.com/p/tortoisegit/wiki/Download
• Try it and I will write some more articles about
  that later on my blog.
• There are 4 more clients check them on git site.
9 February 2013
BitBucket

• BitBucket is a web-based code server and also a
  great management tool for software projects.

• On 29 September 2010, Bitbucket was acquired
  by VC-funded Atlassian. Initially, Bitbucket only
  offered hosting support for Mercurial projects.
  On 3 October 2011, Bitbucket officially
  announced support for Git hosting.


9 February 2013
Why Web-Based Code Hosting?


 Not to be confused with a version control
  system (or SCM system).

 Not a necessity, but good to have for more
  effective collaboration


9 February 2013
Why BitBucket?

• Bitbucket is completely free if you have a .edu
  email address.

• Gives any one any number of repositories,
  free for only 5 users, otherwise see the
  payment on their site.
• Site: https://bitbucket.org


9 February 2013
Creating Repository




9 February 2013
Repository Page




o Notice these buttons in the right.
o Simple design that gives you only what you want
  from a code hosting, no noisy design.
o Notice the menu ( overview, source, commits, pull
  requests, issues, wiki, downloads)
        This menu has the most important functionality that
            bitbucket provide for us.
        In the right of the menu is the settings of repository
9 February 2013
Let’s get a tour in the site features



     Try Demos with
    Online Repositories

9 February 2013
End of the workshop

                  Thanks
                    Medhat Dawoud
                    www.medhatdawoud.com
                        /med7atdawoud
                        /med7atdawoud


9 February 2013

More Related Content

What's hot

What's hot (20)

Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
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
 
Git - An Introduction
Git - An IntroductionGit - An Introduction
Git - An Introduction
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Bitbucket and Git
Bitbucket and GitBitbucket and Git
Bitbucket and Git
 
Bitbucket Devops PPT.pptx
Bitbucket Devops PPT.pptxBitbucket Devops PPT.pptx
Bitbucket Devops PPT.pptx
 
Git installation and configuration
Git installation and configurationGit installation and configuration
Git installation and configuration
 
Introduction to Version Control
Introduction to Version ControlIntroduction to Version Control
Introduction to Version Control
 
Git 101
Git 101Git 101
Git 101
 
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overviewGit and GitHub | Concept about Git and GitHub Process | Git Process overview
Git and GitHub | Concept about Git and GitHub Process | Git Process overview
 
Git best practices workshop
Git best practices workshopGit best practices workshop
Git best practices workshop
 
Git flow for daily use
Git flow for daily useGit flow for daily use
Git flow for daily use
 
Workshop on Git and GitHub
Workshop on Git and GitHubWorkshop on Git and GitHub
Workshop on Git and GitHub
 
Git flow
Git flowGit flow
Git flow
 
Devops and git basics
Devops and git basicsDevops and git basics
Devops and git basics
 
Intro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucketIntro to Git, GitHub, and BitBucket
Intro to Git, GitHub, and BitBucket
 
Git & SourceTree
Git & SourceTreeGit & SourceTree
Git & SourceTree
 
Git workflows
Git workflowsGit workflows
Git workflows
 
Git
GitGit
Git
 

Viewers also liked

Introduction to Git(BitBucket) , Continuous Integration (Bamboo) & Confluence
Introduction to Git(BitBucket) , Continuous Integration (Bamboo) & Confluence Introduction to Git(BitBucket) , Continuous Integration (Bamboo) & Confluence
Introduction to Git(BitBucket) , Continuous Integration (Bamboo) & Confluence Parag Gajbhiye
 
FishEye and Crucible Presentation
FishEye and Crucible PresentationFishEye and Crucible Presentation
FishEye and Crucible PresentationEllen Feaheny
 
Continuous Integration with Bamboo for Salesforce
Continuous Integration with Bamboo for SalesforceContinuous Integration with Bamboo for Salesforce
Continuous Integration with Bamboo for SalesforceKlea Kolaric
 
Points.com fisheye crucible code reviews 2011
Points.com fisheye crucible code reviews 2011Points.com fisheye crucible code reviews 2011
Points.com fisheye crucible code reviews 2011pointstechgeeks
 
How Atlassian Scales Bitbucket Data Center on AWS
How Atlassian Scales Bitbucket Data Center on AWSHow Atlassian Scales Bitbucket Data Center on AWS
How Atlassian Scales Bitbucket Data Center on AWSAtlassian
 
Building on the Shoulders of Giants: the Story of Bitbucket Pipelines
Building on the Shoulders of Giants: the Story of Bitbucket PipelinesBuilding on the Shoulders of Giants: the Story of Bitbucket Pipelines
Building on the Shoulders of Giants: the Story of Bitbucket PipelinesAtlassian
 
Introduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guideIntroduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guideRohit Arora
 
Git and jira
Git and jiraGit and jira
Git and jiraBinBin He
 
Process and Challenges for Upgrading OC, RDC and TMS
 Process and Challenges for Upgrading OC, RDC and TMS Process and Challenges for Upgrading OC, RDC and TMS
Process and Challenges for Upgrading OC, RDC and TMSPerficient
 
git-and-bitbucket
git-and-bitbucketgit-and-bitbucket
git-and-bitbucketazwildcat
 
Continuous Integration - Software development lifecycle for Force.com projects
Continuous Integration - Software development lifecycle for Force.com projectsContinuous Integration - Software development lifecycle for Force.com projects
Continuous Integration - Software development lifecycle for Force.com projectsAldo Fernandez
 
Automating the Impossible: End to End Team Development for ISVs (October 14, ...
Automating the Impossible: End to End Team Development for ISVs (October 14, ...Automating the Impossible: End to End Team Development for ISVs (October 14, ...
Automating the Impossible: End to End Team Development for ISVs (October 14, ...Salesforce Partners
 
How we use Bitbucket to build Bitbucket
How we use Bitbucket to build BitbucketHow we use Bitbucket to build Bitbucket
How we use Bitbucket to build BitbucketShunsuke (Sean) Osawa
 
Using Bitbucket and Mercurial
Using Bitbucket and MercurialUsing Bitbucket and Mercurial
Using Bitbucket and MercurialGramener
 
Bitbucket as a Platform - Atlassian Summit 2012
Bitbucket as a Platform - Atlassian Summit 2012 Bitbucket as a Platform - Atlassian Summit 2012
Bitbucket as a Platform - Atlassian Summit 2012 Atlassian
 
AtlasCamp 2015: Bitbucket: Building kick-ass tools for 2.5M developers
AtlasCamp 2015:  Bitbucket: Building kick-ass tools for 2.5M developersAtlasCamp 2015:  Bitbucket: Building kick-ass tools for 2.5M developers
AtlasCamp 2015: Bitbucket: Building kick-ass tools for 2.5M developersAtlassian
 

Viewers also liked (20)

Introduction to Git(BitBucket) , Continuous Integration (Bamboo) & Confluence
Introduction to Git(BitBucket) , Continuous Integration (Bamboo) & Confluence Introduction to Git(BitBucket) , Continuous Integration (Bamboo) & Confluence
Introduction to Git(BitBucket) , Continuous Integration (Bamboo) & Confluence
 
Bitbucket and git
Bitbucket and gitBitbucket and git
Bitbucket and git
 
FishEye and Crucible Presentation
FishEye and Crucible PresentationFishEye and Crucible Presentation
FishEye and Crucible Presentation
 
Continuous Integration with Bamboo for Salesforce
Continuous Integration with Bamboo for SalesforceContinuous Integration with Bamboo for Salesforce
Continuous Integration with Bamboo for Salesforce
 
Points.com fisheye crucible code reviews 2011
Points.com fisheye crucible code reviews 2011Points.com fisheye crucible code reviews 2011
Points.com fisheye crucible code reviews 2011
 
How Atlassian Scales Bitbucket Data Center on AWS
How Atlassian Scales Bitbucket Data Center on AWSHow Atlassian Scales Bitbucket Data Center on AWS
How Atlassian Scales Bitbucket Data Center on AWS
 
Building on the Shoulders of Giants: the Story of Bitbucket Pipelines
Building on the Shoulders of Giants: the Story of Bitbucket PipelinesBuilding on the Shoulders of Giants: the Story of Bitbucket Pipelines
Building on the Shoulders of Giants: the Story of Bitbucket Pipelines
 
Introduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guideIntroduction to Git/Github - A beginner's guide
Introduction to Git/Github - A beginner's guide
 
Git from SVN
Git from SVNGit from SVN
Git from SVN
 
Git with bitbucket
Git with bitbucketGit with bitbucket
Git with bitbucket
 
Git and jira
Git and jiraGit and jira
Git and jira
 
Process and Challenges for Upgrading OC, RDC and TMS
 Process and Challenges for Upgrading OC, RDC and TMS Process and Challenges for Upgrading OC, RDC and TMS
Process and Challenges for Upgrading OC, RDC and TMS
 
git-and-bitbucket
git-and-bitbucketgit-and-bitbucket
git-and-bitbucket
 
Continuous Integration - Software development lifecycle for Force.com projects
Continuous Integration - Software development lifecycle for Force.com projectsContinuous Integration - Software development lifecycle for Force.com projects
Continuous Integration - Software development lifecycle for Force.com projects
 
Automating the Impossible: End to End Team Development for ISVs (October 14, ...
Automating the Impossible: End to End Team Development for ISVs (October 14, ...Automating the Impossible: End to End Team Development for ISVs (October 14, ...
Automating the Impossible: End to End Team Development for ISVs (October 14, ...
 
How we use Bitbucket to build Bitbucket
How we use Bitbucket to build BitbucketHow we use Bitbucket to build Bitbucket
How we use Bitbucket to build Bitbucket
 
Using Bitbucket and Mercurial
Using Bitbucket and MercurialUsing Bitbucket and Mercurial
Using Bitbucket and Mercurial
 
fms9_cwp_php_en
fms9_cwp_php_enfms9_cwp_php_en
fms9_cwp_php_en
 
Bitbucket as a Platform - Atlassian Summit 2012
Bitbucket as a Platform - Atlassian Summit 2012 Bitbucket as a Platform - Atlassian Summit 2012
Bitbucket as a Platform - Atlassian Summit 2012
 
AtlasCamp 2015: Bitbucket: Building kick-ass tools for 2.5M developers
AtlasCamp 2015:  Bitbucket: Building kick-ass tools for 2.5M developersAtlasCamp 2015:  Bitbucket: Building kick-ass tools for 2.5M developers
AtlasCamp 2015: Bitbucket: Building kick-ass tools for 2.5M developers
 

Similar to Using Git and BitBucket

Bitbucket as a code server and pmt
Bitbucket as a code server and pmt Bitbucket as a code server and pmt
Bitbucket as a code server and pmt malike4u
 
Introduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
Introduction to Git and Github - Google Developer Student Clubs CET, TrivandrumIntroduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
Introduction to Git and Github - Google Developer Student Clubs CET, TrivandrumAbhijitNarayan2
 
You're doing it wrong! Git it right!
You're doing it wrong! Git it right!You're doing it wrong! Git it right!
You're doing it wrong! Git it right!Cory Webb
 
git github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxgit github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxAbelPhilipJoseph
 
Introduction to git and Github
Introduction to git and GithubIntroduction to git and Github
Introduction to git and GithubWycliff1
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in UnityRifauddin Tsalitsy
 
Presentation on Repository Control System
Presentation on Repository Control SystemPresentation on Repository Control System
Presentation on Repository Control SystemMd. Mujahid Islam
 
Introduction to Git for Network Engineers (Lab Guide)
Introduction to Git for Network Engineers (Lab Guide)Introduction to Git for Network Engineers (Lab Guide)
Introduction to Git for Network Engineers (Lab Guide)Joel W. King
 

Similar to Using Git and BitBucket (20)

Bitbucket as a code server and pmt
Bitbucket as a code server and pmt Bitbucket as a code server and pmt
Bitbucket as a code server and pmt
 
Git Basics
Git BasicsGit Basics
Git Basics
 
Mini-training: Let’s Git It!
Mini-training: Let’s Git It!Mini-training: Let’s Git It!
Mini-training: Let’s Git It!
 
Git Training
Git TrainingGit Training
Git Training
 
Git Series - Part 1
Git Series - Part 1 Git Series - Part 1
Git Series - Part 1
 
Introduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
Introduction to Git and Github - Google Developer Student Clubs CET, TrivandrumIntroduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
Introduction to Git and Github - Google Developer Student Clubs CET, Trivandrum
 
You're doing it wrong! Git it right!
You're doing it wrong! Git it right!You're doing it wrong! Git it right!
You're doing it wrong! Git it right!
 
Git hub
Git hubGit hub
Git hub
 
Git 101
Git 101Git 101
Git 101
 
git github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxgit github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptx
 
Introduction to git and Github
Introduction to git and GithubIntroduction to git and Github
Introduction to git and Github
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Git Overview
Git OverviewGit Overview
Git Overview
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in Unity
 
1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx
 
Git
GitGit
Git
 
Git workshop
Git workshopGit workshop
Git workshop
 
git2.ppt
git2.pptgit2.ppt
git2.ppt
 
Presentation on Repository Control System
Presentation on Repository Control SystemPresentation on Repository Control System
Presentation on Repository Control System
 
Introduction to Git for Network Engineers (Lab Guide)
Introduction to Git for Network Engineers (Lab Guide)Introduction to Git for Network Engineers (Lab Guide)
Introduction to Git for Network Engineers (Lab Guide)
 

More from Medhat Dawoud

More from Medhat Dawoud (13)

Real time web
Real time webReal time web
Real time web
 
Introduction to linux
Introduction to linuxIntroduction to linux
Introduction to linux
 
Select your career
Select your careerSelect your career
Select your career
 
Intro to t sql – 3rd session
Intro to t sql – 3rd sessionIntro to t sql – 3rd session
Intro to t sql – 3rd session
 
Intro to T-SQL - 1st session
Intro to T-SQL - 1st sessionIntro to T-SQL - 1st session
Intro to T-SQL - 1st session
 
Intro to T-SQL – 2nd session
Intro to T-SQL – 2nd sessionIntro to T-SQL – 2nd session
Intro to T-SQL – 2nd session
 
Mesh cloud (road to mongoDB)
Mesh cloud (road to mongoDB)Mesh cloud (road to mongoDB)
Mesh cloud (road to mongoDB)
 
Before start
Before startBefore start
Before start
 
DevMix Startup
DevMix StartupDevMix Startup
DevMix Startup
 
Threading in C#
Threading in C#Threading in C#
Threading in C#
 
How to python
How to pythonHow to python
How to python
 
Program threats
Program threatsProgram threats
Program threats
 
Unusual C# - OOP
Unusual C# - OOPUnusual C# - OOP
Unusual C# - OOP
 

Using Git and BitBucket

  • 1. Git and BitBucket Medhat Dawoud /med7atdawoud /med7atdawoud 9 February 2013
  • 2. This workshop will include Source Code Management Systems Web-Based Code Hosting Popular open source projects using SCM Intro to Git Let’s try Git Commands Bitbucket as a web code server and management tool 9 February 2013
  • 3. Source Code Management System • It’s a way that we use to store projects’ source code files in a tree of versions. • With no deal, all those SCMs creators build them on the same rules and structure. • A lot of popular open source projects source codes are collected together all over the world using SCM systems. 9 February 2013
  • 4. SCM Systems Examples Lots of this type of software was created like: 9 February 2013
  • 5. Web based Code Hosting • We can use SCMS on our machine locally that manage the code for you and create versions. • but you can also host your code on web, this solution make it very secure and no lose of data under any circumstances. 9 February 2013
  • 6. Web based Code Hosting Examples A lot of Web-Based Code Servers provide Free and paid services Like: 9 February 2013
  • 7. Popular projects that use web-based code Hosting and Source Code Management Systems Source1: https://git.wiki.kernel.org/index.php/GitProjects 9 February 2013 Source2: https://github.com/popular/starred
  • 8. Popular projects that use web-based code Hosting and Source Code Management Systems Source1: https://git.wiki.kernel.org/index.php/GitProjects 9 February 2013 Source2: https://github.com/popular/starred
  • 9. Popular projects that use web-based code Hosting and Source Code Management Systems Source1: https://git.wiki.kernel.org/index.php/GitProjects 9 February 2013 Source2: https://github.com/popular/starred
  • 10. Popular projects that use web-based code Hosting and Source Code Management Systems Source1: https://git.wiki.kernel.org/index.php/GitProjects 9 February 2013 Source2: https://github.com/popular/starred
  • 11. SCMS • We approved before when we start that all SCMSs are built on the same structure without any deal between them. • Those all are called Source Code Management Systems (SCMSs). • Main task of any SCMS is to:  Track changes to files.  Repository / database of changes  Working directory / current state 9 February 2013
  • 12. SCMS Operations We can sort operations that we can do with any SCMS into 4 main categories:  Bootstrap (init, checkout, switch branch)  Modify (add, delete, rename, commit)  Information (status, diff, log)  Reference (tag, branch) 9 February 2013
  • 13. Types of SCMS There are 2 types of SCM systems:  Centralized SCM  Distributed SCM 9 February 2013
  • 15. Centralized SCM o Examples: Subversion, CVS, etc. o Everything goes to the server, commit changes to the sever, checkout the latest revision from the server. o No direct exchange between developers o Operations require server, there are some drawbacks:  Single point of failure  Bottleneck 9 February 2013
  • 17. Decentralized SCM o Examples: Git, Mercurial, Bazaar, etc. o Each copy of repository is identical and self-sufficient o No need for a central server, but one may choose to have one o Developers may directly exchange change sets over Wi-Fi at a local coffee shop :D o Workflow : – Clone – Pull / fetch – push 9 February 2013
  • 18. Ok, Let’s Start that workshop now • Yes, it was just an intro to the Source Code Management Mechanism and the Web-Based Code Servers. • Now to start talking in our session, I packed Git as our SCM or VCS and BitBucket as a Web-based Code Server and management tool will be discussed later. Are you Ready? 9 February 2013
  • 19. What is Git ?  Decentralized or Destributed Source Code Management(SCMS).  Superior branching and merging mechanism.  Support various protection devices against corruption.  Supported by various code servers. 9 February 2013
  • 20. Git History • 2002  Linus uses BitKeeper to track Linux.  And BK gets Better, and Linux scale better. • April 6, 2005  BitKeeper drops free license.  Linus write his own SCM, Git. • April 18, 2005  Git can merge. • June 16, 2006  Git is officially used to track Linux. • Feb 14, 2007  Git 1.5.0 is released.  Major usability efforts. 9 February 2013
  • 21. “ Nothing is perfect. Git is just *closer* to perfect than any other SCM out there ” - Linus 9 February 2013
  • 22. Git First use • If you are using Git for the first time, you will need to download the server into your machine according to your operation system. • Just go to: http://git-scm.com/downloads and choose the suitable download and install it. 9 February 2013
  • 23. Git First use continue .. • If you are using linux you will find a command that will install Git from terminal. • For example if you are using Ubuntu you will write this command in you terminal: 9 February 2013
  • 24. Git Command line • Now you have installed Git on your machine and you can go to terminal or CMD according to you OS and write any command, for example: $ git –-version this command returned the version of Git you have installed, you should find the result as follow: 9 February 2013
  • 25. Git Commands • Ok, there is a general structure of the git command that all commands use as follow: $ git <options> command <options> • Git includes approximately 137 commands. • Actually we don’t use all of them every day, so I’ll review here the every day use commands and let you check others. 9 February 2013
  • 26. Git Common commands Add status rm push mv pull branch merge checkout log clone init commit diff 9 February 2013
  • 27. Git Help • For any new command for you and need a brief documentation for it use this: $ git <command> -h • When you need a complete help you should write the following command and it will open a web page locally with the full docs for this command: $ git <command> --help or $ git help <command> 9 February 2013
  • 28. Git Bootstrap • Open the project work space (directory) and run this command inside it: $ git init this will create .git directory • This directory (.git) include all meta data about versions and commits, working trees, changes, all configurations, … . 9 February 2013
  • 29. Git Staging • Staging means specifying files that you will commit to the server. • Additions: $ git add file #This add a specific file $ git add . #This add all changed files • Removal: $ git rm file #This removes a specific file • Renames: $ git mv old new #This renames a specific file 9 February 2013
  • 30. .gitignore file • You can create a .gitignore file in your project directory and add files or directories that you need not to add to the server, examples for unwanted files:  Automatically generated code (e.g. R.java for Android)  Settings folder of editors that is created automatically.  If you are using any dependences on other libraries like in PHP you can add them to composer.json and ignore them.  Or any other unwanted files. • So when you use add all files, git will automatically ignore the list of files you have written in this file. 9 February 2013
  • 31. Git Commit • Commit means to apply changes of staged files or all files to the repository locally. • Commit changes must provided by a message that you explain in what is the changes in your commit from the last version: $ git commit –m ”this is the message” • The above command commit only the staged files but if you want to commit all files you should use this: $ git commit -a –m ”this is the message” • This means that the commit command here in applied on your machine only ??? …. The answer is yes 9 February 2013
  • 32. Git work flow from work to commit 9 February 2013
  • 33. Git information • You can use status: $ git status to shows : • Staged • Unstaged • Untracked • You can use show: $ git show that shows the last commit information, changes, author, and date. It has some more configurations that customize the result. 9 February 2013
  • 34. Git information Git show additions:  Just shows stats $ git show –-stat  Just shows name and status $ git show -–name-status 9 February 2013
  • 35. Git information • To review the latest commits or even all commits on some repository we use log command as follow: $ git log • But you can also limit it to review commits in a specific period or in some branch or last 5 for example: $ git log -5 or $ git log -1 master@{yesterday} or $ git log --author=medhatdawoud • There are lots of additions see in docs or help. 9 February 2013
  • 36. References Tags Branches 9 February 2013
  • 37. References • References are used to point to commits.  To get the local branches we use: $ git branch –l  To get the remote branches we use: $ git branch –r  And to get the local tags we use: $ git tag -l 9 February 2013
  • 38. References • Creating new branch to HEAD: $ git branch name new branch “name” on HEAD • Creating new branch to a commit: $ git branch name commit new branch “name” on that commit 9 February 2013
  • 39. References • Switching to branch: $ git checkout name • We have option of creating and switching in the same command: $ git checkout -b name • If you are switching to a branch that has changes, the switching might gives error, then you should merge with switch: $ git checkout -m name 9 February 2013
  • 40. Merging • If your HEAD is referring to a branch and want to merge it to other branch, simply use the following command, assume we have A, B branches, $ git checkout A $ git merge B Assume that we have A, B, C branches and want to merge them all in one command. $ git checkout A $ git merge B C 9 February 2013
  • 41. Cloning • If you have a remote code server on some host and want to get that repository on local, you just want to write this: $ git clone <remote> • This will create a directory to the current root, with the same name of the repository you are cloning. 9 February 2013
  • 42. Let’s Play with 9 February 2013
  • 43. What’s Next ? • Git is already installed into some editors like eclipse, aptana, … Search for your editor installation. • There is a good free book for git, I recommend it for you to be more efficient in using Git as a Source Code Management System, check it from this link: http://progit.org 9 February 2013
  • 44. An other Easy and Fast Solution • I’ll tell you about another easy solution for windows users, it’s a git client with great GUI that makes every thing for you, it’s TortoiseGit • Simply go to this link, download and install: http://code.google.com/p/tortoisegit/wiki/Download • Try it and I will write some more articles about that later on my blog. • There are 4 more clients check them on git site. 9 February 2013
  • 45. BitBucket • BitBucket is a web-based code server and also a great management tool for software projects. • On 29 September 2010, Bitbucket was acquired by VC-funded Atlassian. Initially, Bitbucket only offered hosting support for Mercurial projects. On 3 October 2011, Bitbucket officially announced support for Git hosting. 9 February 2013
  • 46. Why Web-Based Code Hosting?  Not to be confused with a version control system (or SCM system).  Not a necessity, but good to have for more effective collaboration 9 February 2013
  • 47. Why BitBucket? • Bitbucket is completely free if you have a .edu email address. • Gives any one any number of repositories, free for only 5 users, otherwise see the payment on their site. • Site: https://bitbucket.org 9 February 2013
  • 49. Repository Page o Notice these buttons in the right. o Simple design that gives you only what you want from a code hosting, no noisy design. o Notice the menu ( overview, source, commits, pull requests, issues, wiki, downloads)  This menu has the most important functionality that bitbucket provide for us.  In the right of the menu is the settings of repository 9 February 2013
  • 50. Let’s get a tour in the site features Try Demos with Online Repositories 9 February 2013
  • 51. End of the workshop Thanks Medhat Dawoud www.medhatdawoud.com /med7atdawoud /med7atdawoud 9 February 2013