SlideShare una empresa de Scribd logo
1 de 51
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

Django로 만든 웹 애플리케이션 도커라이징하기 + 도커 컴포즈로 개발 환경 구축하기
Django로 만든 웹 애플리케이션 도커라이징하기 + 도커 컴포즈로 개발 환경 구축하기Django로 만든 웹 애플리케이션 도커라이징하기 + 도커 컴포즈로 개발 환경 구축하기
Django로 만든 웹 애플리케이션 도커라이징하기 + 도커 컴포즈로 개발 환경 구축하기raccoony
 
FFMPEG on android
FFMPEG on androidFFMPEG on android
FFMPEG on androidYoss Cohen
 
Optimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for DockerOptimizing Spring Boot apps for Docker
Optimizing Spring Boot apps for DockerGraham Charters
 
Screenshot as a service
Screenshot as a serviceScreenshot as a service
Screenshot as a serviceKAI CHU CHUNG
 
Concourse CI Meetup Demo
Concourse CI Meetup DemoConcourse CI Meetup Demo
Concourse CI Meetup DemoToshiaki 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 LFSTim Pettersen
 
Google apps script introduction
Google apps script introductionGoogle apps script introduction
Google apps script introductionKAI CHU CHUNG
 
Terminus, the Pantheon command-line interface
Terminus, the Pantheon command-line interfaceTerminus, the Pantheon command-line interface
Terminus, the Pantheon command-line interfaceJon Peck
 
GCE 上搭配 Cloud Storage 建置 Drone CI
 GCE 上搭配 Cloud Storage 建置 Drone CI GCE 上搭配 Cloud Storage 建置 Drone CI
GCE 上搭配 Cloud Storage 建置 Drone CIMING JUI Chen
 
Drupal Development : Tools, Tips, and Tricks
Drupal Development : Tools, Tips, and TricksDrupal Development : Tools, Tips, and Tricks
Drupal Development : Tools, Tips, and TricksGerald 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 DrupalCampLAJesus Manuel Olivas
 
Docker Demo @ IuK Seminar
Docker Demo @ IuK SeminarDocker Demo @ IuK Seminar
Docker Demo @ IuK SeminarMartin Scharm
 
Kotlin 讀書會第三梯次第一章
Kotlin 讀書會第三梯次第一章Kotlin 讀書會第三梯次第一章
Kotlin 讀書會第三梯次第一章Shengyou Fan
 
IzPack - PoitouJUG
IzPack - PoitouJUGIzPack - PoitouJUG
IzPack - PoitouJUGjulien.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 2016Tim Pettersen
 
Contribuir a Drupal - Entorno
Contribuir a Drupal - EntornoContribuir a Drupal - Entorno
Contribuir a Drupal - EntornoKeopx
 
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜Retrieva inc.
 

La actualidad más candente (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コンテナ〜
 

Destacado

aramanstudio | lifestyle
aramanstudio | lifestylearamanstudio | lifestyle
aramanstudio | lifestylearaman
 
Sumi-e - by www.aramanstudio.com
Sumi-e - by www.aramanstudio.comSumi-e - by www.aramanstudio.com
Sumi-e - by www.aramanstudio.comaraman
 
Universidad de los ángeles claudia
Universidad de los ángeles claudiaUniversidad de los ángeles claudia
Universidad de los ángeles claudiaclausibu
 
aramanstudio | fashion
aramanstudio | fashionaramanstudio | fashion
aramanstudio | fashionaraman
 
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 MomentsForest 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.comaraman
 

Destacado (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 a GTFO: Git Theory For OpenSource

Similar a 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
 

Último

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 

Último (20)

The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 

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