Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Gündelik Hayatta GIT İpuçları

Gündelik Hayatta GIT İpuçları

Phpkonf 2015'te yaptığım sunum.
http://phpkonf.org/

Uğur Özyılmazel

July 26, 2015
Tweet

More Decks by Uğur Özyılmazel

Other Decks in Programming

Transcript

  1. GIT İPUÇLARI
    G Ü N D E L İ K H A Y A T T A
    Uğur “vigo” Özyılmazel

    View Slide

  2. HELP

    View Slide

  3. git help -a

    View Slide

  4. add
    add--interactive
    am
    annotate
    apply
    archive
    bisect
    bisect--helper
    blame
    branch
    bundle
    cat-file
    check-attr
    check-ignore
    check-mailmap
    check-ref-format
    checkout
    checkout-index
    cherry
    cherry-pick
    clean
    clone
    column
    commit
    commit-tree
    config
    count-objects
    credential
    credential-cache
    credential-cache--daemon
    credential-store
    daemon
    describe
    diff
    diff-files
    diff-index
    diff-tree
    difftool
    difftool--helper
    fast-export
    fast-import
    fetch
    fetch-pack
    filter-branch
    fmt-merge-msg
    for-each-ref
    format-patch
    fsck
    fsck-objects
    gc
    get-tar-commit-id
    grep
    hash-object
    help
    http-backend
    http-fetch
    http-push
    imap-send
    index-pack
    init
    init-db
    instaweb
    log
    ls-files
    ls-remote
    ls-tree
    mailinfo
    mailsplit
    merge
    merge-base
    merge-file
    merge-index
    merge-octopus
    merge-one-file
    merge-ours
    merge-recursive
    merge-resolve
    merge-subtree
    merge-tree
    mergetool
    mktag
    mktree
    mv
    name-rev
    notes
    pack-objects
    pack-redundant
    pack-refs
    patch-id
    prune
    prune-packed
    pull
    push
    quiltimport
    read-tree
    rebase
    receive-pack
    reflog
    relink
    remote
    remote-ext
    remote-fd
    remote-ftp
    remote-ftps
    remote-http
    remote-https
    remote-testsvn
    repack
    replace
    request-pull
    rerere
    reset
    rev-list
    rev-parse
    revert
    rm
    send-pack
    sh-i18n--envsubst
    shell
    shortlog
    show
    show-branch
    show-index
    show-ref
    stage
    stash
    status
    stripspace
    submodule
    subtree
    symbolic-ref
    tag
    unpack-file
    unpack-objects
    update-index
    update-ref
    update-server-info
    upload-archive
    upload-pack
    var
    verify-commit
    verify-pack
    verify-tag
    web--browse
    whatchanged
    write-tree
    146+ KOMUT

    View Slide

  5. git help -g

    View Slide

  6. git help
    attributes
    everyday
    glossary
    ignore
    modules
    revisions
    tutorial
    workflows

    View Slide

  7. TAG

    View Slide

  8. git tag v0.0.1

    View Slide

  9. git tag -a v0.0.1
    -m "İlk versiyon"

    View Slide

  10. git tag

    View Slide

  11. git ls-remote --tags

    View Slide

  12. git describe

    View Slide

  13. git describe HEAD

    View Slide

  14. * 6006b9c (feature/1a) feature1a added
    * 26447ed (HEAD -> master) JSON service3 file added
    * 241004e JSON service2 file added
    * eafcd77 JSON service file added
    | * 3d118d6 (feature/1) feature1 added
    |/
    * 023ee17 (tag: v0.0.2) "Hello World" string added to index.html
    * 45e83cb (tag: v0.0.1) Rakefile added for automated tasks
    * c5bb57d HTML index file added
    * 7b87937 JS index file added
    * 4cbb412 RUBY application file added
    * 1d034b5 PYTHON source file added
    * ef7d3f5 PHP index file added
    * fb52add Initial commit
    v0.0.2-3-g26447ed

    View Slide

  15. * 6006b9c (feature/1a) feature1a added
    * 26447ed (HEAD -> master) JSON service3 file added
    * 241004e (1) JSON service2 file added
    * eafcd77 (2) JSON service file added
    | * 3d118d6 (feature/1) feature1 added
    |/
    * 023ee17 (3) (tag: v0.0.2) "Hello World" string added to
    index.html
    * 45e83cb (tag: v0.0.1) Rakefile added for automated tasks
    * c5bb57d HTML index file added
    * 7b87937 JS index file added
    * 4cbb412 RUBY application file added
    * 1d034b5 PYTHON source file added
    * ef7d3f5 PHP index file added
    v0.0.2-3-g26447ed

    View Slide

  16. git describe
    [email protected]{1.week.ago}

    View Slide

  17. REVİZYON

    View Slide

  18. git show

    View Slide

  19. git show HEAD

    View Slide

  20. git show 023ee17

    View Slide

  21. git show v2.1.5

    View Slide

  22. git show feature/1

    View Slide

  23. git show eafcd77^1

    View Slide

  24. git show eafcd77~2

    View Slide

  25. git show
    [email protected]{yesterday}

    View Slide

  26. git show
    [email protected]{1.minute.ago}

    View Slide

  27. git show :/kelime

    View Slide

  28. git checkout -

    View Slide

  29. git branch --merged

    View Slide

  30. git branch --no-merged

    View Slide

  31. git branch

    --contains :/kelime

    View Slide

  32. BUNDLE

    View Slide

  33. git bundle create
    ~/project.bundle
    master

    View Slide

  34. git ls-remote

    ~/project.bundle

    View Slide

  35. ae3cc4b38c2a3b737a87
    3397c1c086b30bf9d1c5
    refs/heads/master

    View Slide

  36. git clone ~/
    project.bundle -b master
    friends-repo

    View Slide

  37. * 40f6f9b (HEAD -> master) friend added 2 files
    * ae3cc4b (origin/master) 2 files added
    * 465fea2 Initial commit

    View Slide

  38. git log --oneline master
    ^origin/master

    View Slide

  39. 40f6f9b friend added 2 files

    View Slide

  40. git bundle create

    ~/friends.bundle master
    ^origin/master

    View Slide

  41. cd repo/
    git bundle verify

    ~/friends.bundle

    View Slide

  42. The bundle contains this ref:
    40f6f9b757c0a21cc9496689a3db11382831f345
    refs/heads/master
    The bundle requires this ref:
    ae3cc4b38c2a3b737a873397c1c086b30bf9d1c5
    ~/friends.bundle is okay

    View Slide

  43. git fetch

    ~/friends.bundle
    master:friends-master

    View Slide

  44. git log --graph

    --decorate --oneline

    --all

    View Slide

  45. * 40f6f9b (friends-master) friend added 2 files
    * ae3cc4b (HEAD -> master) 2 files added
    * 465fea2 Initial commit

    View Slide

  46. REMOTE

    View Slide

  47. git branch -av

    View Slide

  48. git remote
    update origin

    View Slide

  49. git remote
    update origin

    --prune

    View Slide

  50. TRACKING

    View Slide

  51. git checkout

    -b BRANCH
    origin/BRANCH

    View Slide

  52. git checkout

    -t origin/BRANCH

    View Slide

  53. git push -u
    REMOTE BRANCH

    View Slide

  54. git branch --set-upstream-
    to=REMOTE/BRANCH BRANCH

    View Slide

  55. HISTORY

    View Slide

  56. git commit --allow-
    empty

    View Slide

  57. git commit --amend

    View Slide

  58. git commit --amend
    --no-edit

    View Slide

  59. REBASING

    View Slide

  60. * ca3fdfe (HEAD -> master) file6 added
    | * 6e5c748 (feature) file5 added
    | * 29a8cf0 file4 added
    |/
    * fdadf1f file3 added
    * 941b2e4 file2 added
    * 089ee87 file1 added
    * 61bd5c1 Initial commit

    View Slide

  61. 089ee87
    941b2e4
    fdadf1f
    ca3fdfe
    29a8cf0
    6e5c748
    feature
    HEAD -> master

    View Slide

  62. 941b2e4
    089ee87
    fdadf1f
    ca3fdfe
    HEAD -> master
    29a8cf0
    6e5c748
    feature

    View Slide

  63. 941b2e4
    089ee87
    fdadf1f
    ca3fdfe
    HEAD -> master
    29a8cf0
    6e5c748
    feature

    View Slide

  64. * c035db3 (HEAD -> master) file6 added
    * 6e5c748 (feature) file5 added
    * 29a8cf0 file4 added
    * fdadf1f file3 added
    * 941b2e4 file2 added
    * 089ee87 file1 added
    * 61bd5c1 Initial commit

    View Slide

  65. git checkout master

    View Slide

  66. git rebase BRANCH

    View Slide

  67. git rebase -i @{u}

    View Slide

  68. SQUASH

    View Slide

  69. git rebase -i

    View Slide

  70. * 7d0bc97 Added yet another missing text to README
    * 4ff7ba1 Added another missing text to README
    * 31f1560 Added missing text to README
    * dcb8071 JSON service3 file added - amend
    * bb2f23b JSON service2 file added
    * 2911c52 JSON service file added

    View Slide

  71. * 7d0bc97 Added yet another missing text to README
    * 4ff7ba1 Added another missing text to README
    * 31f1560 Added missing text to README
    * dcb8071 JSON service3 file added - amend
    * bb2f23b JSON service2 file added
    * 2911c52 JSON service file added

    View Slide

  72. git rebase -i
    dcb8071

    View Slide

  73. pick 31f1560 Added missing text to README
    pick 4ff7ba1 Added another missing text to README
    pick 7d0bc97 Added yet another missing text to README
    pick 31f1560 Added missing text to README
    squash 4ff7ba1 Added another missing text to README
    squash 7d0bc97 Added yet another missing text to README

    View Slide

  74. # This is a combination of 3 commits.
    # The first commit's message is:
    Added missing text to README
    # This is the 2nd commit message:
    Added another missing text to README
    # This is the 3rd commit message:
    Added yet another missing text to README
    # Please enter the commit message for your changes. Lines starting
    # with '#' will be ignored, and an empty message aborts the commit.
    #
    # Date: Wed Jul 15 09:05:25 2015 +0300
    #
    # rebase in progress; onto dcb8071
    # You are currently editing a commit while rebasing branch 'master' on 'dcb8071'.
    #
    # Changes to be committed:
    # modified: README.md
    #

    View Slide

  75. 917b8ea README file updated
    dcb8071 JSON service3 file added - amend
    bb2f23b JSON service2 file added
    2911c52 JSON service file added

    View Slide

  76. git reset --soft
    HEAD~3

    View Slide

  77. SPLIT

    View Slide

  78. * c2109ee (HEAD -> master) did many things
    * 3c7b147 file2 added
    * c502494 file1 added
    * 41b8cc1 init

    View Slide

  79. git rebase -i HEAD^

    View Slide

  80. pick c2109ee did many things

    View Slide

  81. edit c2109ee did many things

    View Slide

  82. git reset HEAD^

    View Slide

  83. rebase in progress; onto 3c7b147
    You are currently editing a commit while rebasing branch 'master' on '3c7b147'.
    (use "git commit --amend" to amend the current commit)
    (use "git rebase --continue" once you are satisfied with your changes)
    Untracked files:
    (use "git add ..." to include in what will be committed)
    test_file1
    test_file2
    test_file3
    test_file4
    nothing added to commit but untracked files present (use "git add" to track)

    View Slide

  84. git add test_file1
    test_file2

    View Slide

  85. git commit -m "test_file1
    and test_file2 added"

    View Slide

  86. git add test_file3
    test_file4

    View Slide

  87. git commit -m "test_file3
    and test_file4 added"

    View Slide

  88. git rebase --continue

    View Slide

  89. * 82d30b2 (HEAD -> master) test_file3 and test_file4 added
    * ed68764 test_file1 and test_file2 added
    * 3c7b147 file2 added
    * c502494 file1 added
    * 41b8cc1 init

    View Slide

  90. * c2109ee (HEAD -> master) did many things
    * 3c7b147 file2 added
    * c502494 file1 added
    * 41b8cc1 init

    View Slide

  91. LOG

    View Slide

  92. git log --graph

    --decorate --oneline
    --all

    View Slide

  93. * 83d0d2d (HEAD -> master, origin/master, origin/HEAD) added what_is_my_public_ip
    alias for showing public ip address
    * d485193 Docker IP support for PS1
    * 4d9679d gentoo specific fixes
    * 9a4b867 Merge branch 'master' of github.com:vigo/dotfiles-universal
    |\
    | * 09b9f6d mysql prompt fixed
    * | 13dbcc5 nano 2.4.2 support
    |/
    * 91a3a86 virtualenv prompt fix: display django version info if django exists
    * cd1990b mysql.server status indicator for PS1
    * f3f39fe Screen shot updated
    * 5af3b2f AirDrop / Ethernet hack added to osx tweaks
    * 60c916e Merge branch 'master' of github.com:vigo/dotfiles-universal
    |\
    | * 60bedb1 nano version 2.4.1 for nanorc
    * | b84ba0b ctags files are ignored
    |/
    * 2a434d6 virtualenv, python and django version info for prompt
    * ae39932 bash-completion for django: manage.py and django-admin.py

    View Slide

  94. git notes edit SHA

    View Slide

  95. git notes show SHA

    View Slide

  96. git notes show
    HEAD

    View Slide

  97. commit dcb807137280386cdc1d38e2327656d1c088124c
    Author: Uğur Özyılmazel
    Date: Tue Jul 14 13:41:39 2015 +0300
    JSON service3 file added - amend
    Notes:
    Bu bir test notudur!

    View Slide

  98. REFLOG

    View Slide

  99. 8670327 [email protected]{0}: checkout: moving from master to feature2
    8670327 [email protected]{1}: cherry-pick: file2-a added
    3c7b147 [email protected]{2}: checkout: moving from feature to master
    af2a355 [email protected]{3}: commit: file2-a added
    3c7b147 [email protected]{4}: checkout: moving from master to feature
    3c7b147 [email protected]{5}: commit: file2 added
    c502494 [email protected]{6}: commit: file1 added
    41b8cc1 [email protected]{7}: commit (initial): init

    View Slide

  100. 8670327 [email protected]{0}: checkout: moving from master to feature2
    8670327 [email protected]{1}: cherry-pick: file2-a added
    3c7b147 [email protected]{2}: checkout: moving from feature to master
    af2a355 [email protected]{3}: commit: file2-a added
    3c7b147 [email protected]{4}: checkout: moving from master to feature
    3c7b147 [email protected]{5}: commit: file2 added
    c502494 [email protected]{6}: commit: file1 added
    41b8cc1 [email protected]{7}: commit (initial): init

    View Slide

  101. git reset --hard 3c7b147

    View Slide

  102. git reset --hard [email protected]{7}

    View Slide

  103. 3c7b147 [email protected]{0}: reset: moving to 3c7b147
    8670327 [email protected]{1}: checkout: moving from 3c7b14747431c36db72775d00db2e76e8775ba47 to master
    3c7b147 [email protected]{2}: checkout: moving from feature2 to 3c7b147
    8670327 [email protected]{3}: checkout: moving from master to feature2
    8670327 [email protected]{4}: cherry-pick: file2-a added
    3c7b147 [email protected]{5}: checkout: moving from feature to master
    af2a355 [email protected]{6}: commit: file2-a added
    3c7b147 [email protected]{7}: checkout: moving from master to feature
    3c7b147 [email protected]{8}: commit: file2 added
    c502494 [email protected]{9}: commit: file1 added
    41b8cc1 [email protected]{10}: commit (initial): init

    View Slide

  104. COMMIT

    View Slide

  105. Kısa açıklama maksimum 50 karakterden oluşmalı
    Daha detaylı açıklamalar paragraflar halinde uzun uzun yazılabilir ve 72
    karakter boyunda satırlardan oluşması önerilmektedir. Örneğin GitHub,
    commit mesajının title'i yani başlığı olarak ilk satırı göstermektedir.
    Paragraflar arasında 1 satır boşluk bırakılması önerilir.
    - Bullet list ya da liste şekli
    - Yine birer satır aralık verilmesi önerilir.
    * Çizgi / Dash yerine yıldız da kullanılabilir

    View Slide

  106. PATCH

    View Slide

  107. git add -p

    View Slide

  108. $ git add -p
    diff --git a/file1 b/file1
    index 70177a7..2d2e1d1 100644
    --- a/file1
    +++ b/file1
    @@ -1,2 +1,4 @@
    Hello World
    Hello World as second line
    +Hello World as 3rd line
    +Hello World as 4th line
    Stage this hunk [y,n,q,a,d,/,e,?]? ?
    y - stage this hunk
    n - do not stage this hunk
    q - quit; do not stage this hunk or any of the remaining ones
    a - stage this hunk and all later hunks in the file
    d - do not stage this hunk or any of the later hunks in the file
    g - select a hunk to go to
    / - search for a hunk matching the given regex
    j - leave this hunk undecided, see next undecided hunk
    J - leave this hunk undecided, see next hunk
    k - leave this hunk undecided, see previous undecided hunk
    K - leave this hunk undecided, see previous hunk
    s - split the current hunk into smaller hunks
    e - manually edit the current hunk
    ? - print help
    @@ -1,2 +1,4 @@
    Hello World
    Hello World as second line
    +Hello World as 3rd line
    +Hello World as 4th line
    Stage this hunk [y,n,q,a,d,/,e,?]?

    View Slide

  109. BISECT

    View Slide

  110. git bisect start

    View Slide

  111. * 82d30b2 (HEAD -> master) test_file3 and test_file4 added
    * ed68764 test_file1 and test_file2 added
    * 3c7b147 file2 added
    * c502494 file1 added
    * 41b8cc1 init

    View Slide

  112. git bisect bad

    View Slide

  113. * 82d30b2 (HEAD -> master, refs/bisect/bad) test_file3 and test_file4 added
    * ed68764 test_file1 and test_file2 added
    * 3c7b147 file2 added
    * c502494 file1 added
    * 41b8cc1 init

    View Slide

  114. git checkout 3c7b147

    View Slide

  115. git bisect good

    View Slide

  116. Bisecting: 0 revisions left to test after this
    (roughly 0 steps)
    [ed68764cd0098bf143248e8d293d6c1a0ac2d848]
    test_file1 and test_file2 added

    View Slide

  117. * 82d30b2 (master, refs/bisect/bad) test_file3 and test_file4 added
    * ed68764 (HEAD) test_file1 and test_file2 added
    * 3c7b147 (refs/bisect/good-3c7b14747431c36db72775d00db2e76e8775ba47) file2 added
    * c502494 file1 added
    * 41b8cc1 init

    View Slide

  118. git bisect reset

    View Slide

  119. TÜYOLAR

    View Slide

  120. git diff --word-diff

    View Slide

  121. diff --git a/file2 b/file2
    index e69de29..3b18e51 100644
    --- a/file2
    +++ b/file2
    @@ -0,0 +1 @@
    +hello world

    View Slide

  122. diff --git a/file2 b/file2
    index e69de29..3b18e51 100644
    --- a/file2
    +++ b/file2
    @@ -0,0 +1 @@
    {+hello world+}

    View Slide

  123. git status -sb

    View Slide

  124. ## master
    M file1
    A file3
    AM file4
    ?? file5

    View Slide

  125. git config --global
    pull.rebase true

    View Slide

  126. git config --global
    push.default
    tracking

    View Slide

  127. git config --global
    rerere.enabled true

    View Slide

  128. git instaweb

    View Slide

  129. git instaweb start

    View Slide

  130. View Slide

  131. git instaweb stop

    View Slide

  132. KONFİGÜRASYON

    View Slide

  133. /etc/gitconfig

    Sistem --system

    ~/.gitconfig

    Kullanıcı --global


    $GIT_DIR/config
    Proje --local

    View Slide

  134. git config --global

    View Slide

  135. git config --system

    View Slide

  136. git config --local

    View Slide

  137. KaynAKLAR

    View Slide

  138. https://github.com/mislav
    https://github.com/schacon
    https://github.com/singingwolfboy
    http://vigo.github.io/git-tips/

    View Slide

  139. TEŞEKKÜRLER
    vigobronx vigo

    View Slide