SlideShare a Scribd company logo
GIT
            THEORY
            FOR
            OPEN
by Forest   SOURCE
Mars

                     11/4/30
“Using Git for web development is
like Shopping for groceries in a
Ferrari”
Source                       Source

Code                         Code


           SCCS
Control                      Managment

System              VCS      Software


Software        SVSC         Configuration

                             Management
Version     RCS    SVC
Control                      Concurrent

System        SCM            Versioning

                             System
Version           SCMS
            SCM              Centralised
Control

System
                       CVS   Version

                             System


                             Version
Distributed

       Version

       Control

       System




DVCS
Distributed

       Revision

       Control

       System




DRCS
Speed

Lightweight

Distributed

Security

Code Integrity

Easy branching
GITTING STARTED

                   LINUX

$ sudo yum install git gitweb

$ sudo aptitude install git-core gitweb


                    OSX

$ sudo port install git-core

osx-git-installer:
code.google.com/p/git-osx-installer/
Installing Git the Recommended Way:

# GPG (if you didn't have it already)
curl ftp://ftp.gnupg.org/gcrypt/gnupg/gnupg-
1.4.7.tar.bz2 tar xj
cd gnupg-1.4.7
./configure
make
sudo make install
cd ..

# GetText
curl http://mirrors.usc.edu/pub/gnu/gettext/gettext-
0.17.tar.gz tar xz
cd gettext-0.17
./configure
make
sudo make install
cd ..
Installing Git the Recommended Way:


# GIT
curl http://kernel.org/pub/software/scm/git/git-
1.5.5.tar.bz2 tar xj
cd git-1.5.5
./configure
make
sudo make install
cd ..
curl http://www.kernel.org/pub/software/scm/git/git-
manpages-1.5.5.tar.bz2 
sudo tar xj -C /usr/local/share/man
git config --global user.name "Forest Mars"

git config --global user.email
forest@15382.no-reply.drupal.org

git config --global user.xmpp
“twitter.com/forestmars”

git config --global user.irc
“kombucha”

$ git config --global color.status auto

$ git config --global color.branch auto

$ git config --global color.diff auto
git protocol

$ git clone
git://github.com/drupal/drupal.git



           http protocol

$ git clone
http://github.com/drupal/drupal.git
git protocol

$ git clone
git://git.drupal.org/project/drupal



           http protocol

$ git clone
http://git.drupal.org/project/drupal
PS1='[u@h W$(__git_ps1 " (%s)")]$ '




[forest@githubris gtfo (master)]:
$ git

usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path]
           [-p|--paginate|--no-pager] [--no-replace-objects]
           [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE]
           [-c name=value] [--help]
           COMMAND [ARGS]

The most commonly used git commands are:
   add        Add file contents to the index
   bisect     Find by binary search the change that introduced a bug
   branch     List, create, or delete branches
   checkout   Checkout a branch or paths to the working tree
   clone      Clone a repository into a new directory
   commit     Record changes to the repository
   diff       Show changes between commits, commit and working tree, etc
   fetch      Download objects and refs from another repository
   grep       Print lines matching a pattern
   init       Create an empty git repository or reinitialize an existing one
   log        Show commit logs
   merge      Join two or more development histories together
   mv         Move or rename a file, a directory, or a symlink
   pull       Fetch from and merge with another repository or a local branch
   push       Update remote refs along with associated objects
   rebase     Forward-port local commits to the updated upstream head
   reset      Reset current HEAD to the specified state
   rm         Remove files from the working tree and from the index
   show       Show various types of objects
   status     Show the working tree status
   tag        Create, list, delete or verify a tag object signed with GPG
$ git add .

$ git commit -a -m “commit
message”

$ git push
WORKING WITH REMOTES

$ git remote add origin
git@host:repo-name.git

$ git remote add origin
forest@git.drupal.org
:sandbox/forest/project.git

$ git remote add github
git@github.com:forestmars/example.g
it

$ git remote -v
(What if I need to make my
     repo bare later?)

$ git config --bool core.bare true
Quite possibly the most
   useful slide in this deck

$ git describe

$ git status

$ git ls-files

$ git diff

$ git log --since=2.weeks

$ git foo –help
Wait I was wrong, this is the
    really important one:

$ git commit --ammend

$ git checkout HEAD some_file

$ git revert HEAD^

$ git revert HEAD~1 -m 1

$ git reset --hard HEAD

$ git reset --hard [reflog-id]
DON'T LOSE YOUR HEAD




  $ git checkout HEAD

  $ git reset --hard HEAD
IN EVENT OF CATASTROPHIC FAILURE (or where's the
               Undo-Undo button?)
[forest@githubris gtfo (master)]$ git add somefile

[forest@githubris gtfo (master)]$ git commit -m "updated some file"
[master 7ff5b1e] updated some file
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 somefile

[forest@githubris gtfo (master)]$ cat somefile
contents of somefile

[forest@githubris gtfo (master)]$ git reset --hard HEAD^
HEAD is now at 15dae3b somefile

[forest@githubris gtfo (master)]$ cat somefile
cat: otherfile: No such file or directory

[forest@baird gtfo (master)]$ git reflog
15dae3b HEAD@{0}: HEAD^: updating HEAD
7ff5b1e HEAD@{1}: commit: updated some file

[forest@githubris gtfo (master)]$ git reset --hard 7ff5b1e
HEAD is now at 7ff5b1e updated some file

[forest@githubris gtfo (master)]$ cat somefile
CLONE

FETCH

CHECKOUT

PRUNE
CLONE

FETCH

CHECKOUT

PRUNE
git clone --branch 7.x
git://git.drupal.org/project/drupal.git ./
$ git clone --branch master
http://git.drupal.org:project/devel.git

$ git clone -b '6.x-3.x'
git://git.drupal.org/project/admin_menu.git
$ git clone --branch 7.x
git://git.drupal.org/project/some_module.git
./

$ cd some_module

$ (edit files)

$ git add (files)

$ git commit -m 'Explain what I changed'
$ git clone --branch master
http://git.drupal.org:project/devel.git

$ git clone -b '6.x-3.x'
git://git.drupal.org/project/admin_menu.git
$ git clone --branch 7.x
git://git.drupal.org/project/some_module.git
./

$ cd some_module

$ (edit files)

$ git add (files)

$ git commit -m 'Explain what I changed'
CLONE

       FETCH

       CHECKOUT

       PRUNE



$ got fetch origin
[remote-branch]:[new-local-branch]
CLONE

       FETCH

       CHECKOUT

       PRUNE



$ git checkout -b some_branch origin/some_branch
CLONE

       FETCH

       CHECKOUT

       PRUNE



$ git remote prune -v [remote-repo]
BRANCHING
$ git branch
  * master

$ git branch new_branch

$ git checkout -b new_branch
[old_branch_name]

$ git branch -r -d origin/
[new_branch_name]

$ git branch --track ... origin/...
$ git branch
  * master
    new_feature

$ git merge new_feature

$ git branch new_branch

$ git rebase

$ git pull --rebase

$ git rebase -i

$ git rebase
PUSH ME PULL YOU
$ git push
$ git push origin master

$ git push origin [branch-name]

$ git push [remote-repo]
LOCALBRANCHNAME:REMOTEBRANCHNAME

 default behavior of git is to push matching refs,
 so git push <remote-repo> would not push branch if it is not
present on <remote-repo>

$ git push -f –all

Once the local branch is pushed to the remote, execute:

$ git --set-upstream [local-branch] origin/[branch-name]

to make the local branch track the remote branch.

$ git push -n --dryrun
The Dirtiest Git Hack You Will Ever
                 See


$ git push upstream
upstreammaster:master
! [rejected] master -> master (non-
fast forward)

$ git push origin :master

$ git push origin master
$ git clone forest@git.drupal.org
:sandbox/forest//1140078.git

Cloning into /1140078...

forest@git.drupal.org's password:
$ git clone forest@git.drupal.org
:sandbox/forest//1140078.git

Cloning into /1140078...

forest@git.drupal.org's password:


$ git clone git@git.drupal.org
:sandbox/forest//1140078.git

Cloning into /1140078...
$ echo 'name = "My Awesome Module"' >
1140078.info

$ echo '<?php>' > my_awesome.module
$ git status
 On branch master

 Initial commit

 Untracked files:
   (use "git add <file>..." to include in
what will be committed)

  1140078.info
  my_awesome.module
nothing added to commit but untracked files
present (use "git add" to track)
$ git add .

$ git commit -m “initial commit”

$ git push origin master

Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 300 bytes,
done.
Total 3 (delta 2), reused 0 (delta 0)
To
forest@git.drupal.org:sandbox/forest//114007
8.git
   1a8d48d..f6dcf5d master -> master
linkedin.com/in/forestmars

    twitter.com/forestmars

       about.me/forestmars




                   THANX!
                  twitter.com/forestmars
Adding Bash Completion for Git on Mac OS X Snow Leopard

                             cd /tmp && git clone
                             git://git.kernel.org/pub/scm/g
                             it/git.git

                             cd git && git checkout v`git
                             --version | awk '{print $3}'`
                             cp contrib/completion/git-
                             completion.bash ~/.git-
                             completion.bash

                             Cd ~ && rm -rf /tmp/git
                             echo -e "source ~/.git-
                             completion.bash" >> .profile

                             sudo port install git-core
                             +bash_completion

                             if [ -ftwitter.com/forestmars
                             /opt/local/etc/bash_completion
                             ]; then     .
                             /opt/local/etc/bash_completion
                             fi
GTFO: Git Theory For OpenSource

More Related Content

What's hot

Django로 만든 웹 애플리케이션 도커라이징하기 + 도커 컴포즈로 개발 환경 구축하기
Django로 만든 웹 애플리케이션 도커라이징하기 + 도커 컴포즈로 개발 환경 구축하기Django로 만든 웹 애플리케이션 도커라이징하기 + 도커 컴포즈로 개발 환경 구축하기
Django로 만든 웹 애플리케이션 도커라이징하기 + 도커 컴포즈로 개발 환경 구축하기
raccoony
 
FFMPEG on android
FFMPEG on androidFFMPEG on android
FFMPEG on android
Yoss Cohen
 
Optimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for DockerOptimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for Docker
Graham Charters
 
Light my-fuse
Light my-fuseLight my-fuse
Light my-fuse
Workhorse Computing
 
Screenshot as a service
Screenshot as a serviceScreenshot as a service
Screenshot as a service
KAI CHU CHUNG
 
Concourse CI Meetup Demo
Concourse CI Meetup DemoConcourse CI Meetup Demo
Concourse CI Meetup Demo
Toshiaki Maki
 
Tracking large game assets with Git LFS
Tracking large game assets with Git LFSTracking large game assets with Git LFS
Tracking large game assets with Git LFS
Tim Pettersen
 
Google apps script introduction
Google apps script introductionGoogle apps script introduction
Google apps script introduction
KAI CHU CHUNG
 
Terminus, the Pantheon command-line interface
Terminus, the Pantheon command-line interfaceTerminus, the Pantheon command-line interface
Terminus, the Pantheon command-line interface
Jon Peck
 
GCE 上搭配 Cloud Storage 建置 Drone CI
 GCE 上搭配 Cloud Storage 建置 Drone CI GCE 上搭配 Cloud Storage 建置 Drone CI
GCE 上搭配 Cloud Storage 建置 Drone CI
MING JUI Chen
 
Git vs svn
Git vs svnGit vs svn
Git vs svn
Suman Mukherjee
 
Drupal Development : Tools, Tips, and Tricks
Drupal Development : Tools, Tips, and TricksDrupal Development : Tools, Tips, and Tricks
Drupal Development : Tools, Tips, and Tricks
Gerald Villorente
 
Improving your Drupal 8 development workflow DrupalCampLA
Improving your Drupal 8 development workflow DrupalCampLAImproving your Drupal 8 development workflow DrupalCampLA
Improving your Drupal 8 development workflow DrupalCampLA
Jesus Manuel Olivas
 
Docker Demo @ IuK Seminar
Docker Demo @ IuK SeminarDocker Demo @ IuK Seminar
Docker Demo @ IuK Seminar
Martin Scharm
 
Kotlin 讀書會第三梯次第一章
Kotlin 讀書會第三梯次第一章Kotlin 讀書會第三梯次第一章
Kotlin 讀書會第三梯次第一章
Shengyou Fan
 
IzPack - PoitouJUG
IzPack - PoitouJUGIzPack - PoitouJUG
IzPack - PoitouJUG
julien.ponge
 
Tracking huge files with Git LFS - LinuxCon 2016
Tracking huge files with Git LFS - LinuxCon 2016Tracking huge files with Git LFS - LinuxCon 2016
Tracking huge files with Git LFS - LinuxCon 2016
Tim Pettersen
 
Contribuir a Drupal - Entorno
Contribuir a Drupal - EntornoContribuir a Drupal - Entorno
Contribuir a Drupal - Entorno
Keopx
 
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
Retrieva inc.
 

What's hot (19)

Django로 만든 웹 애플리케이션 도커라이징하기 + 도커 컴포즈로 개발 환경 구축하기
Django로 만든 웹 애플리케이션 도커라이징하기 + 도커 컴포즈로 개발 환경 구축하기Django로 만든 웹 애플리케이션 도커라이징하기 + 도커 컴포즈로 개발 환경 구축하기
Django로 만든 웹 애플리케이션 도커라이징하기 + 도커 컴포즈로 개발 환경 구축하기
 
FFMPEG on android
FFMPEG on androidFFMPEG on android
FFMPEG on android
 
Optimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for DockerOptimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for Docker
 
Light my-fuse
Light my-fuseLight my-fuse
Light my-fuse
 
Screenshot as a service
Screenshot as a serviceScreenshot as a service
Screenshot as a service
 
Concourse CI Meetup Demo
Concourse CI Meetup DemoConcourse CI Meetup Demo
Concourse CI Meetup Demo
 
Tracking large game assets with Git LFS
Tracking large game assets with Git LFSTracking large game assets with Git LFS
Tracking large game assets with Git LFS
 
Google apps script introduction
Google apps script introductionGoogle apps script introduction
Google apps script introduction
 
Terminus, the Pantheon command-line interface
Terminus, the Pantheon command-line interfaceTerminus, the Pantheon command-line interface
Terminus, the Pantheon command-line interface
 
GCE 上搭配 Cloud Storage 建置 Drone CI
 GCE 上搭配 Cloud Storage 建置 Drone CI GCE 上搭配 Cloud Storage 建置 Drone CI
GCE 上搭配 Cloud Storage 建置 Drone CI
 
Git vs svn
Git vs svnGit vs svn
Git vs svn
 
Drupal Development : Tools, Tips, and Tricks
Drupal Development : Tools, Tips, and TricksDrupal Development : Tools, Tips, and Tricks
Drupal Development : Tools, Tips, and Tricks
 
Improving your Drupal 8 development workflow DrupalCampLA
Improving your Drupal 8 development workflow DrupalCampLAImproving your Drupal 8 development workflow DrupalCampLA
Improving your Drupal 8 development workflow DrupalCampLA
 
Docker Demo @ IuK Seminar
Docker Demo @ IuK SeminarDocker Demo @ IuK Seminar
Docker Demo @ IuK Seminar
 
Kotlin 讀書會第三梯次第一章
Kotlin 讀書會第三梯次第一章Kotlin 讀書會第三梯次第一章
Kotlin 讀書會第三梯次第一章
 
IzPack - PoitouJUG
IzPack - PoitouJUGIzPack - PoitouJUG
IzPack - PoitouJUG
 
Tracking huge files with Git LFS - LinuxCon 2016
Tracking huge files with Git LFS - LinuxCon 2016Tracking huge files with Git LFS - LinuxCon 2016
Tracking huge files with Git LFS - LinuxCon 2016
 
Contribuir a Drupal - Entorno
Contribuir a Drupal - EntornoContribuir a Drupal - Entorno
Contribuir a Drupal - Entorno
 
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
 

Viewers also liked

aramanstudio | lifestyle
aramanstudio | lifestylearamanstudio | lifestyle
aramanstudio | lifestyle
araman
 
Sumi-e - by www.aramanstudio.com
Sumi-e - by www.aramanstudio.comSumi-e - by www.aramanstudio.com
Sumi-e - by www.aramanstudio.com
araman
 
Universidad de los ángeles claudia
Universidad de los ángeles claudiaUniversidad de los ángeles claudia
Universidad de los ángeles claudia
clausibu
 
aramanstudio | fashion
aramanstudio | fashionaramanstudio | fashion
aramanstudio | fashion
araman
 
Fiche_de_Communication_Dyma_confection-1
Fiche_de_Communication_Dyma_confection-1Fiche_de_Communication_Dyma_confection-1
Fiche_de_Communication_Dyma_confection-1abdoulaye diouf
 
Linux & Free Software: 5 Myths & 10 Crucial Moments
Linux & Free Software: 5 Myths & 10 Crucial MomentsLinux & Free Software: 5 Myths & 10 Crucial Moments
Linux & Free Software: 5 Myths & 10 Crucial Moments
Forest Mars
 
The Beautiful Iga - by www.aramanstudio.com
The Beautiful Iga - by www.aramanstudio.comThe Beautiful Iga - by www.aramanstudio.com
The Beautiful Iga - by www.aramanstudio.com
araman
 

Viewers also liked (7)

aramanstudio | lifestyle
aramanstudio | lifestylearamanstudio | lifestyle
aramanstudio | lifestyle
 
Sumi-e - by www.aramanstudio.com
Sumi-e - by www.aramanstudio.comSumi-e - by www.aramanstudio.com
Sumi-e - by www.aramanstudio.com
 
Universidad de los ángeles claudia
Universidad de los ángeles claudiaUniversidad de los ángeles claudia
Universidad de los ángeles claudia
 
aramanstudio | fashion
aramanstudio | fashionaramanstudio | fashion
aramanstudio | fashion
 
Fiche_de_Communication_Dyma_confection-1
Fiche_de_Communication_Dyma_confection-1Fiche_de_Communication_Dyma_confection-1
Fiche_de_Communication_Dyma_confection-1
 
Linux & Free Software: 5 Myths & 10 Crucial Moments
Linux & Free Software: 5 Myths & 10 Crucial MomentsLinux & Free Software: 5 Myths & 10 Crucial Moments
Linux & Free Software: 5 Myths & 10 Crucial Moments
 
The Beautiful Iga - by www.aramanstudio.com
The Beautiful Iga - by www.aramanstudio.comThe Beautiful Iga - by www.aramanstudio.com
The Beautiful Iga - by www.aramanstudio.com
 

Similar to GTFO: Git Theory For OpenSource

Git
GitGit
Git and github 101
Git and github 101Git and github 101
Git and github 101
Senthilkumar Gopal
 
A Quick Start - Version Control with Git
A Quick Start - Version Control with GitA Quick Start - Version Control with Git
A Quick Start - Version Control with Git
Dmitry Sheiko
 
Git
GitGit
Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Brian K. Vagnini
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
Arpit Mohan
 
Git presentation
Git presentationGit presentation
Git presentation
James Cuzella
 
Git setuplinux
Git setuplinuxGit setuplinux
Git setuplinux
Shubham Verma
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
Becky Todd
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
Mahmoud Said
 
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
Rifauddin Tsalitsy
 
Gitosis on Mac OS X Server
Gitosis on Mac OS X ServerGitosis on Mac OS X Server
Gitosis on Mac OS X ServerYasuhiro Asaka
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
Sothearin Ren
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践Terry Wang
 
Git
GitGit
Version Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an exampleVersion Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an example
Gaurav Kumar Garg
 

Similar to GTFO: Git Theory For OpenSource (20)

Git
GitGit
Git
 
Git and github 101
Git and github 101Git and github 101
Git and github 101
 
A Quick Start - Version Control with Git
A Quick Start - Version Control with GitA Quick Start - Version Control with Git
A Quick Start - Version Control with Git
 
Git
GitGit
Git
 
Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615
 
Introduction to GIT
Introduction to GITIntroduction to GIT
Introduction to GIT
 
Hello git
Hello git Hello git
Hello git
 
Git
GitGit
Git
 
Git presentation
Git presentationGit presentation
Git presentation
 
GitSetupLinux
GitSetupLinuxGitSetupLinux
GitSetupLinux
 
Git setuplinux
Git setuplinuxGit setuplinux
Git setuplinux
 
Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
 
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
 
Gitosis on Mac OS X Server
Gitosis on Mac OS X ServerGitosis on Mac OS X Server
Gitosis on Mac OS X Server
 
Understanding about git
Understanding about gitUnderstanding about git
Understanding about git
 
Git
GitGit
Git
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
Git
GitGit
Git
 
Version Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an exampleVersion Control Systems with git (and github) as an example
Version Control Systems with git (and github) as an example
 

Recently uploaded

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 

Recently uploaded (20)

GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 

GTFO: Git Theory For OpenSource

  • 1. GIT THEORY FOR OPEN by Forest SOURCE Mars 11/4/30
  • 2.
  • 3.
  • 4. “Using Git for web development is like Shopping for groceries in a Ferrari”
  • 5.
  • 6. Source Source Code Code SCCS Control Managment System VCS Software Software SVSC Configuration Management Version RCS SVC Control Concurrent System SCM Versioning System Version SCMS SCM Centralised Control System CVS Version System Version
  • 7. Distributed Version Control System DVCS
  • 8. Distributed Revision Control System DRCS
  • 9.
  • 11. GITTING STARTED LINUX $ sudo yum install git gitweb $ sudo aptitude install git-core gitweb OSX $ sudo port install git-core osx-git-installer: code.google.com/p/git-osx-installer/
  • 12. Installing Git the Recommended Way: # GPG (if you didn't have it already) curl ftp://ftp.gnupg.org/gcrypt/gnupg/gnupg- 1.4.7.tar.bz2 tar xj cd gnupg-1.4.7 ./configure make sudo make install cd .. # GetText curl http://mirrors.usc.edu/pub/gnu/gettext/gettext- 0.17.tar.gz tar xz cd gettext-0.17 ./configure make sudo make install cd ..
  • 13. Installing Git the Recommended Way: # GIT curl http://kernel.org/pub/software/scm/git/git- 1.5.5.tar.bz2 tar xj cd git-1.5.5 ./configure make sudo make install cd .. curl http://www.kernel.org/pub/software/scm/git/git- manpages-1.5.5.tar.bz2 sudo tar xj -C /usr/local/share/man
  • 14. git config --global user.name "Forest Mars" git config --global user.email forest@15382.no-reply.drupal.org git config --global user.xmpp “twitter.com/forestmars” git config --global user.irc “kombucha” $ git config --global color.status auto $ git config --global color.branch auto $ git config --global color.diff auto
  • 15. git protocol $ git clone git://github.com/drupal/drupal.git http protocol $ git clone http://github.com/drupal/drupal.git
  • 16. git protocol $ git clone git://git.drupal.org/project/drupal http protocol $ git clone http://git.drupal.org/project/drupal
  • 17. PS1='[u@h W$(__git_ps1 " (%s)")]$ ' [forest@githubris gtfo (master)]:
  • 18. $ git usage: git [--version] [--exec-path[=GIT_EXEC_PATH]] [--html-path] [-p|--paginate|--no-pager] [--no-replace-objects] [--bare] [--git-dir=GIT_DIR] [--work-tree=GIT_WORK_TREE] [-c name=value] [--help] COMMAND [ARGS] The most commonly used git commands are: add Add file contents to the index bisect Find by binary search the change that introduced a bug branch List, create, or delete branches checkout Checkout a branch or paths to the working tree clone Clone a repository into a new directory commit Record changes to the repository diff Show changes between commits, commit and working tree, etc fetch Download objects and refs from another repository grep Print lines matching a pattern init Create an empty git repository or reinitialize an existing one log Show commit logs merge Join two or more development histories together mv Move or rename a file, a directory, or a symlink pull Fetch from and merge with another repository or a local branch push Update remote refs along with associated objects rebase Forward-port local commits to the updated upstream head reset Reset current HEAD to the specified state rm Remove files from the working tree and from the index show Show various types of objects status Show the working tree status tag Create, list, delete or verify a tag object signed with GPG
  • 19. $ git add . $ git commit -a -m “commit message” $ git push
  • 20.
  • 21.
  • 22. WORKING WITH REMOTES $ git remote add origin git@host:repo-name.git $ git remote add origin forest@git.drupal.org :sandbox/forest/project.git $ git remote add github git@github.com:forestmars/example.g it $ git remote -v
  • 23. (What if I need to make my repo bare later?) $ git config --bool core.bare true
  • 24. Quite possibly the most useful slide in this deck $ git describe $ git status $ git ls-files $ git diff $ git log --since=2.weeks $ git foo –help
  • 25. Wait I was wrong, this is the really important one: $ git commit --ammend $ git checkout HEAD some_file $ git revert HEAD^ $ git revert HEAD~1 -m 1 $ git reset --hard HEAD $ git reset --hard [reflog-id]
  • 26. DON'T LOSE YOUR HEAD $ git checkout HEAD $ git reset --hard HEAD
  • 27. IN EVENT OF CATASTROPHIC FAILURE (or where's the Undo-Undo button?) [forest@githubris gtfo (master)]$ git add somefile [forest@githubris gtfo (master)]$ git commit -m "updated some file" [master 7ff5b1e] updated some file 1 files changed, 1 insertions(+), 0 deletions(-) create mode 100644 somefile [forest@githubris gtfo (master)]$ cat somefile contents of somefile [forest@githubris gtfo (master)]$ git reset --hard HEAD^ HEAD is now at 15dae3b somefile [forest@githubris gtfo (master)]$ cat somefile cat: otherfile: No such file or directory [forest@baird gtfo (master)]$ git reflog 15dae3b HEAD@{0}: HEAD^: updating HEAD 7ff5b1e HEAD@{1}: commit: updated some file [forest@githubris gtfo (master)]$ git reset --hard 7ff5b1e HEAD is now at 7ff5b1e updated some file [forest@githubris gtfo (master)]$ cat somefile
  • 30. git clone --branch 7.x git://git.drupal.org/project/drupal.git ./
  • 31. $ git clone --branch master http://git.drupal.org:project/devel.git $ git clone -b '6.x-3.x' git://git.drupal.org/project/admin_menu.git $ git clone --branch 7.x git://git.drupal.org/project/some_module.git ./ $ cd some_module $ (edit files) $ git add (files) $ git commit -m 'Explain what I changed'
  • 32. $ git clone --branch master http://git.drupal.org:project/devel.git $ git clone -b '6.x-3.x' git://git.drupal.org/project/admin_menu.git $ git clone --branch 7.x git://git.drupal.org/project/some_module.git ./ $ cd some_module $ (edit files) $ git add (files) $ git commit -m 'Explain what I changed'
  • 33. CLONE FETCH CHECKOUT PRUNE $ got fetch origin [remote-branch]:[new-local-branch]
  • 34. CLONE FETCH CHECKOUT PRUNE $ git checkout -b some_branch origin/some_branch
  • 35. CLONE FETCH CHECKOUT PRUNE $ git remote prune -v [remote-repo]
  • 37. $ git branch * master $ git branch new_branch $ git checkout -b new_branch [old_branch_name] $ git branch -r -d origin/ [new_branch_name] $ git branch --track ... origin/...
  • 38.
  • 39. $ git branch * master new_feature $ git merge new_feature $ git branch new_branch $ git rebase $ git pull --rebase $ git rebase -i $ git rebase
  • 40. PUSH ME PULL YOU $ git push $ git push origin master $ git push origin [branch-name] $ git push [remote-repo] LOCALBRANCHNAME:REMOTEBRANCHNAME default behavior of git is to push matching refs, so git push <remote-repo> would not push branch if it is not present on <remote-repo> $ git push -f –all Once the local branch is pushed to the remote, execute: $ git --set-upstream [local-branch] origin/[branch-name] to make the local branch track the remote branch. $ git push -n --dryrun
  • 41. The Dirtiest Git Hack You Will Ever See $ git push upstream upstreammaster:master ! [rejected] master -> master (non- fast forward) $ git push origin :master $ git push origin master
  • 42.
  • 43.
  • 44. $ git clone forest@git.drupal.org :sandbox/forest//1140078.git Cloning into /1140078... forest@git.drupal.org's password:
  • 45. $ git clone forest@git.drupal.org :sandbox/forest//1140078.git Cloning into /1140078... forest@git.drupal.org's password: $ git clone git@git.drupal.org :sandbox/forest//1140078.git Cloning into /1140078...
  • 46. $ echo 'name = "My Awesome Module"' > 1140078.info $ echo '<?php>' > my_awesome.module
  • 47. $ git status On branch master Initial commit Untracked files: (use "git add <file>..." to include in what will be committed) 1140078.info my_awesome.module nothing added to commit but untracked files present (use "git add" to track)
  • 48. $ git add . $ git commit -m “initial commit” $ git push origin master Counting objects: 5, done. Delta compression using up to 4 threads. Compressing objects: 100% (3/3), done. Writing objects: 100% (3/3), 300 bytes, done. Total 3 (delta 2), reused 0 (delta 0) To forest@git.drupal.org:sandbox/forest//114007 8.git 1a8d48d..f6dcf5d master -> master
  • 49. linkedin.com/in/forestmars twitter.com/forestmars about.me/forestmars THANX! twitter.com/forestmars
  • 50. Adding Bash Completion for Git on Mac OS X Snow Leopard cd /tmp && git clone git://git.kernel.org/pub/scm/g it/git.git cd git && git checkout v`git --version | awk '{print $3}'` cp contrib/completion/git- completion.bash ~/.git- completion.bash Cd ~ && rm -rf /tmp/git echo -e "source ~/.git- completion.bash" >> .profile sudo port install git-core +bash_completion if [ -ftwitter.com/forestmars /opt/local/etc/bash_completion ]; then . /opt/local/etc/bash_completion fi