SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
$ git kata



        push & pull options

    Other katas NOW (11:30)                    Katas NEXT (12:20)


    Git rebase (Wojtek Erbetowski)             Manipulating commits (Jakub Nabrdalik)

    Submodules (Paweł Cesar Sanjuan Szklarz)   Git flow (Michał Bareja)

    Configs/aliases (Jakub Nabrdalik)          Refspec (Mateusz Grzechociński)

    Branches and tags (Mateusz Harasymczuk)    Merging and rebasing (Mateusz Harasymczuk)

    Git filter-branch (Grzegorz Kubiak)        USB workflow (Łukasz Siwiński)

                                               Rescue stash (Kamil Trzciński)

                                               Undoing changes (Marcin Zajączkowski)




                                                                       Mateusz Grzechociński
                                                                    http://grzechocinski.net
git fetch vs git pull
pull with fast forward
           =
 no merge commit
pull without fast forward
            =
     merge commit
What's better?



             vs


                  http://walkingthestack.blogspot.com/2012/05/why-you-should-use-git-merge-no-ff-
                  when.html
git pull --rebase
git config --global branch.
   autosetuprebase always

    Only for NEW branches
$ git checkout feature/security
Branch feature/security set up to track remote
branch feature/security from origin by
rebasing.
Switched to a new branch feature/security
git config <branch_name>.
      rebase = true

   For EXISTING branches
What about pushes?
● Let's checkout remote "new_feature" as
  "security"
● git checkout -t origin/new_fature
  -b security
● Let's try to push to "new_feature"
First try...




    git push origin security
WRONG
"If :<dst> is omitted, the same ref as <src> will be updated."



         ... so new branch 'security' is
         created :(
Second try...




         git push origin
WTF ???
The special refspec : (or +: to allow non-fast-forward
updates) directs git to push “matching” branches: for every
  branch that exists on the local side, the remote side is
updated if a branch of the same name already exists on
                      the remote side.



       ... so all other branches were
       pushed unintentionally :(
Third try...




               git push
WRONG
Works like git push <remote>, where <remote> is the
current branch’s remote (or origin, if no remote is
        configured for the current branch).


     ... so same as with 'origin' :(
Fourth try...




      git push github HEAD
WRONG
git push origin HEAD
  A handy way to push the current branch to the same name on the remote.




... but HEAD is resolved as security :(
Finally... use refspec!




git push security:new-feature
OK :)
What's the default behavior?
"By default, git push origin will update branches on the
destination with one with the same name on the source,
instead of using the association defined by git branch
--track, which git pull origin would use — the config option
push.default can change this behaviour.”


    http://longair.net/blog/2011/02/27/an-asymmetry-between-git-pull-and-git-push/
git config push.default
●   nothing
●   matching (default)
●   upstream
●   current


Introduced 4 years ago in commit:
https://github.
com/git/git/commit/521537476fe99b97bfcdf1b8f0c579061af5fd3
e
What should be by default?
● simple (not default)
"push to the upstream branch, but only if it has the same name remotely. If
not, give an error that suggests the right command to push explicitely to
'upstream' or 'current'."



Introduced in commit: http://goo.gl/je6gk
Available since 1.7.11 (https://raw.github.com/git/git/master/Documentation/RelNotes/1.7.11.txt)

Ubuntu:
[00:33:03] mgrzechocinski ~ git version
git version 1.7.10.4
git push -u
● set tracking branch
● set push branch
$ git push origin -u topic/feature1
Total 0 (delta 0), reused 0 (delta 0)
To git@github.com:mgrzechocinski/gitkata.git
 * [new branch]      topic/feature1 -> topic/feature1
Branch topic/feature1 set up to track remote branch
topic/feature1 from origin by rebasing.

$ git push
Current branch topic/feature1 is up to date.
$ git pull
Current branch topic/feature1 is up to date.
Next katas

Manipulating commits (Jakub Nabrdalik)
Git flow (Michał Bareja)
Refspec (Mateusz Grzechociński)
Merging and rebasing (Mateusz Harasymczuk)
USB workflow (Łukasz Siwiński)
Rescue stash (Kamil Trzciński)
Undoing changes (Marcin Zajączkowski)




                                                Mateusz Grzechociński
                                             http://grzechocinski.net

Weitere ähnliche Inhalte

Andere mochten auch

Conventions of genre ppt
Conventions of genre pptConventions of genre ppt
Conventions of genre pptryanwheartytwbs
 
İşverenin İş Kazası ve Meslek Hastalığından Doğan Yükümlülükleri
İşverenin İş Kazası ve Meslek Hastalığından Doğan Yükümlülükleriİşverenin İş Kazası ve Meslek Hastalığından Doğan Yükümlülükleri
İşverenin İş Kazası ve Meslek Hastalığından Doğan YükümlülükleriİGY Zirve
 

Andere mochten auch (7)

Gitkata undoing changes
Gitkata undoing changesGitkata undoing changes
Gitkata undoing changes
 
Gitkata rerere
Gitkata rerereGitkata rerere
Gitkata rerere
 
Audience Survey Results
Audience Survey ResultsAudience Survey Results
Audience Survey Results
 
Media powetpoint
Media powetpointMedia powetpoint
Media powetpoint
 
Conventions of genre ppt
Conventions of genre pptConventions of genre ppt
Conventions of genre ppt
 
İşverenin İş Kazası ve Meslek Hastalığından Doğan Yükümlülükleri
İşverenin İş Kazası ve Meslek Hastalığından Doğan Yükümlülükleriİşverenin İş Kazası ve Meslek Hastalığından Doğan Yükümlülükleri
İşverenin İş Kazası ve Meslek Hastalığından Doğan Yükümlülükleri
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 

Ähnlich wie Gitkata push and_pull_options

Ähnlich wie Gitkata push and_pull_options (20)

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
 
Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
 
Git github
Git githubGit github
Git github
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
Loading...git
Loading...gitLoading...git
Loading...git
 
Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)Introduction to Git (Greg Lonnon)
Introduction to Git (Greg Lonnon)
 
Wokshop de Git
Wokshop de Git Wokshop de Git
Wokshop de Git
 
Git training
Git trainingGit training
Git training
 
Get going with_git_ppt
Get going with_git_pptGet going with_git_ppt
Get going with_git_ppt
 
Mastering GIT
Mastering GITMastering GIT
Mastering GIT
 
GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSource
 
Jedi Mind Tricks in Git
Jedi Mind Tricks in GitJedi Mind Tricks in Git
Jedi Mind Tricks in Git
 
GIT Basics
GIT BasicsGIT Basics
GIT Basics
 
Jedi Mind Tricks for Git
Jedi Mind Tricks for GitJedi Mind Tricks for Git
Jedi Mind Tricks for Git
 
Git of every day
Git of every dayGit of every day
Git of every day
 
Git
GitGit
Git
 
From svn to git
From svn to gitFrom svn to git
From svn to git
 
How to use git without rage
How to use git without rageHow to use git without rage
How to use git without rage
 
Hello git
Hello git Hello git
Hello git
 
git fail --force (make it up with your pull requests)
git fail --force (make it up with your pull requests)git fail --force (make it up with your pull requests)
git fail --force (make it up with your pull requests)
 

Gitkata push and_pull_options

  • 1. $ git kata push & pull options Other katas NOW (11:30) Katas NEXT (12:20) Git rebase (Wojtek Erbetowski) Manipulating commits (Jakub Nabrdalik) Submodules (Paweł Cesar Sanjuan Szklarz) Git flow (Michał Bareja) Configs/aliases (Jakub Nabrdalik) Refspec (Mateusz Grzechociński) Branches and tags (Mateusz Harasymczuk) Merging and rebasing (Mateusz Harasymczuk) Git filter-branch (Grzegorz Kubiak) USB workflow (Łukasz Siwiński) Rescue stash (Kamil Trzciński) Undoing changes (Marcin Zajączkowski) Mateusz Grzechociński http://grzechocinski.net
  • 2. git fetch vs git pull
  • 3. pull with fast forward = no merge commit
  • 4. pull without fast forward = merge commit
  • 5. What's better? vs http://walkingthestack.blogspot.com/2012/05/why-you-should-use-git-merge-no-ff- when.html
  • 7. git config --global branch. autosetuprebase always Only for NEW branches
  • 8. $ git checkout feature/security Branch feature/security set up to track remote branch feature/security from origin by rebasing. Switched to a new branch feature/security
  • 9. git config <branch_name>. rebase = true For EXISTING branches
  • 10. What about pushes? ● Let's checkout remote "new_feature" as "security" ● git checkout -t origin/new_fature -b security ● Let's try to push to "new_feature"
  • 11. First try... git push origin security
  • 12. WRONG
  • 13. "If :<dst> is omitted, the same ref as <src> will be updated." ... so new branch 'security' is created :(
  • 14. Second try... git push origin
  • 16. The special refspec : (or +: to allow non-fast-forward updates) directs git to push “matching” branches: for every branch that exists on the local side, the remote side is updated if a branch of the same name already exists on the remote side. ... so all other branches were pushed unintentionally :(
  • 17. Third try... git push
  • 18. WRONG
  • 19. Works like git push <remote>, where <remote> is the current branch’s remote (or origin, if no remote is configured for the current branch). ... so same as with 'origin' :(
  • 20. Fourth try... git push github HEAD
  • 21. WRONG
  • 22. git push origin HEAD A handy way to push the current branch to the same name on the remote. ... but HEAD is resolved as security :(
  • 23. Finally... use refspec! git push security:new-feature
  • 24. OK :)
  • 25. What's the default behavior? "By default, git push origin will update branches on the destination with one with the same name on the source, instead of using the association defined by git branch --track, which git pull origin would use — the config option push.default can change this behaviour.” http://longair.net/blog/2011/02/27/an-asymmetry-between-git-pull-and-git-push/
  • 26. git config push.default ● nothing ● matching (default) ● upstream ● current Introduced 4 years ago in commit: https://github. com/git/git/commit/521537476fe99b97bfcdf1b8f0c579061af5fd3 e
  • 27. What should be by default? ● simple (not default) "push to the upstream branch, but only if it has the same name remotely. If not, give an error that suggests the right command to push explicitely to 'upstream' or 'current'." Introduced in commit: http://goo.gl/je6gk Available since 1.7.11 (https://raw.github.com/git/git/master/Documentation/RelNotes/1.7.11.txt) Ubuntu: [00:33:03] mgrzechocinski ~ git version git version 1.7.10.4
  • 28. git push -u ● set tracking branch ● set push branch $ git push origin -u topic/feature1 Total 0 (delta 0), reused 0 (delta 0) To git@github.com:mgrzechocinski/gitkata.git * [new branch] topic/feature1 -> topic/feature1 Branch topic/feature1 set up to track remote branch topic/feature1 from origin by rebasing. $ git push Current branch topic/feature1 is up to date. $ git pull Current branch topic/feature1 is up to date.
  • 29. Next katas Manipulating commits (Jakub Nabrdalik) Git flow (Michał Bareja) Refspec (Mateusz Grzechociński) Merging and rebasing (Mateusz Harasymczuk) USB workflow (Łukasz Siwiński) Rescue stash (Kamil Trzciński) Undoing changes (Marcin Zajączkowski) Mateusz Grzechociński http://grzechocinski.net