Git mini workshop

Distribution Model

John Doe's laptop

secret-project

github.com/john.doe/secret-project

Jane Doe's laptop

secret-project

github.com/jane.doe/secret-project

github.com

origin

jane

john

origin

$ git remote
origin

$ git remote get-url origin
ssh://git@github.com/kocsismate/php-src.git

$ git remote add upstream ssh://git@git.php.net/php-src.git

$ git remote set-url upstream ssh://git@github.com/kocsismate/php-src.git

Distribution Model

$ git push --atomic upstream master PHP-8.0
remote: Resolving deltas: 100% (529/529), completed with 303 local objects.
To ssh://github.com/kocsismate/php-src.git
   ab4c5976d7..6ec25f386f  PHP-8.0 -> PHP-8.0
   8c14675217..803779e84b  master -> master

Distribution Model

Distribution Model

author vs. co-author vs. committer

commit 1954e5975846b3952ce1d2d6506e6d7134c89684
Author: Máté Kocsis <kocsismate@woohoolabs.com>
Date:   Tue Jan 26 11:50:36 2021 +0100

    Add support for generating class entries from stubs
    
    Closes GH-6289
    
    Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>

Distribution Model

Sharing Changes

$ git format-patch <branch>
$ git am <patch_file>

Integration strategies

Integration strategies

Integration strategies

When, why and how to rebase?

  • when integrating to a private branch
  • when commit order doesn't matter
  • for "clean" commit history
  • for easy rewrites
  • you have to force push the changes!

Integration strategies

When, why and how to merge?

  • when integrating to a shared branch
  • when commit order matters
  • when the integration time matters
  • you can squash your commits: --squash

Integration strategies

Cherry-pick

$ git checkout master
$ git cherry-pick 1734e58e7
$ git show 9cec093b7
commit 9cec093b7fb75fd881d58d0529cc99c3ff256a44
Author: Máté Kocsis <kocsismate@woohoolabs.com>
Date:   Thu Oct 22 10:39:18 2020 +0200
$ git show 9cec093b7f~1
commit 420184ad529443182c9a348a55b1c9216005c613
Author: Christoph M. Becker <cmbecker69@gmx.de>
Date:   Wed Dec 16 00:02:39 2020 +0100

Integration strategies

  • git pull:
    • git fetch + git merge
  • git pull --rebase
    • git fetch + git rebase

Rewriting

Rewriting History

git commit --amend

Rewriting History

git reset HEAD^1

Rewriting History

git commit --fixup

Rewriting History

git rebase --interactive

Debugging

git bisect

$ git bisect start
$ git bisect bad
$ git bisect good 98fb565c74
Bisecting: 8 revisions left to test after this (roughly 3 steps)

✋ Q&A

Made with Slides.com