Skip to content

Latest commit

 

History

History
354 lines (217 loc) · 7.26 KB

index-extras.md

File metadata and controls

354 lines (217 loc) · 7.26 KB

This curriculum will be your companion to the GitHub Advanced class taught by the GitHub Training Team and other educational groups. In this course, you'll explore strategies for branch and history rewriting, temporary storing and recovery techniques, and Git technology mechanics for faster problem solving.

  • Linked list of commits
  • First commit has nil parent
  • Integrity checking with git gc

{% capture slide %}

Branching strategies

{% endcapture %}

Summary

  • GitHub Flow
  • Branch-per-feature
  • Compatibility with Pull Requests
  • git-flow
  • Long-term release support

Details

These are called Branching Strategies, but are just as easily called Team Collaboration Techniques in an abstract discussion of version control.

  • Git's Model
    • Git Maintenance Notes
    • Git Workflows
    • Git's Source Code
    • Branches
      • master
      • maint
      • next (graduation from pu)
      • pu (can be rebased)
      • html
      • man
    • "A trivial and safe enhancement goes directly on top of 'master'."
    • "The two branches "master" and "maint" are never rewound, and "next" usually will not be either"
    • "When a topic that was in 'pu' proves to be in testable shape, it graduates to 'next'."

{% capture slide %}

Applying branching patterns

{% endcapture %}

Summary

  • Breaking features down into pieces
  • Feedback early on Pull Requests
  • @mentioning teams instead of individuals
  • Continuous integration

Further reading

Validated Build Promotions with Git, GitHub, and Jenkins

<iframe width="640" height="480" src="//www.youtube-nocookie.com/embed/Gd8OfAmKkMQ?rel=0" frameborder="0" allowfullscreen></iframe>

Git and GitHub Workflows at the Utah JUG

<script async class="speakerdeck-embed" data-id="111dc3201094013231b066d414c0f9a8" data-ratio="1.77777777777778" src="//speakerdeck.com/assets/embed.js"></script>

{% capture slide %}

Git-core GUIs

{% endcapture %}

Summary

{% capture slide %}

Mastering Shortcuts

{% endcapture %}

{% capture slide %}

{% endcapture %}

{% capture slide %}

Branch best practices

{% endcapture %}

  • Pros/cons of collapsing commits during merge
  • Relation to branching strategies and deliverable expectations
  • Checking merge state
  • Cleaning up branches
$ git merge --squash [branch]

Querying commit existence:

$ git branch --contains [commit]

List branches with this merged in:

$ git branch --merged [commit]

List branches without this merged in:

$ git branch --no-merged [commit]

{% capture slide %}

Navigating History

{% endcapture %}

Further reading

{% capture slide %}

Incorporating History

{% endcapture %}

More examples

$ git cherry-pick [ref]
$ git cherry-pick [ref1] [ref2]

$ git branch --contains [noncherrypickedref]
$ git cherry [upstreambranch]

+ bd650366fa8c39f03cfc9dd5290f60e7331a631d
+ ea62f9f6a7cef55a8a3028e617d28819408a63c4
+ 874628c0e405390130d6457776273451bb66d3a8
+ 046a9b8d0f2363361e45cfbc7e0f6d82968f2f9f
+ 315fe16408f9a9080527e00df3d9a8c1ba0dc97a

{% capture slide %}

Rewriting history with rebase

{% endcapture %}

Fixing Branches

  • This mode of rebase change where branch history begins
  • Moving blocks of history around

To change which base a branch is placed upon:

$ git rebase --onto <newbase> <upstream> <HEAD|branch>

Further reading

{% capture slide %}

Cutting Releases

{% endcapture %}

{% capture slide %}

Reviewing & synchronizing

{% endcapture %}

Maintaining, customizing remotes

  • Remove non-matching local remote branches
  • Remove non-matching remote upstream branches
  • Remove only remote upstream branch
# Discard remote local branches
# not present on upstream
$ git fetch --prune

# Delete an upstream branch
$ git push origin :<branch-name>

Customizing Interaction

  • Specification for retrieval and pushing
  • Implied on fetch, pull, and push
  • Altered by option switches like --tags
  • Stored in .git/config
  • Ability to retrieve Pull Request branches
$ git fetch [repo-url] [source]:[destination]
$ git config --add remote.[upstream].fetch "+refs/pull/*/head:refs/remotes/[upstream]/pull/*"

{% capture slide %}

Aggregating repositories

{% endcapture %}

Dependencies with subtree
  • Alternative to submodule
  • All files available advantage

First a remote connecting to the dependency and a branch in which to read from is needed.

$ git remote add
    [dependency-bookmark]
    [repository-url]

$ git fetch [dependency-bookmark]

$ git branch [branch]
    [dependency-bookmark]/[branch]
  • Notice the working tree content differs between the dependency and the main project.
  • Establishing the association of a subdirectory and the branch is necessary when creating the association.
  • Whenever the branch needs updating, switch to it, retrieve the changes and commit them against the main project branch(es).
$ git read-tree
  --prefix=[directory]/
    -u [branch]
$ git merge --squash
  -s subtree [branch]

{% capture slide %}

Signing work

{% endcapture %}

By commit message

Adds a rigorously formatted text block to commit messages:

{% capture slide %}

Cleaning

{% endcapture %}

{% capture slide %}

Diff & merge tool

{% endcapture %}

Summary

  • P4Merge
  • Opendiff
  • KDiff
  • Kaleidoscope
  • Vimdiff
  • Meld

Details

Difftool execution:

$ git difftool --tool-help
$ git config diff.tool <tool-name-in-config>
$ git config difftool.prompt false
$ git config difftool.<tool-name>.cmd "<path [args]>"

A sample .gitconfig file:

[diff]
    tool = p4merge
[difftool "p4merge"]
    cmd = "/Applications/p4merge.app/Contents/Resources/launchp4merge $LOCAL $REMOTE"
[difftool]
    prompt = false

Mergetool execution:

$ git config --global merge.tool p4mergetool

$ git config --global mergetool.p4mergetool.cmd "/Applications/p4merge.app/Contents/Resources/launchp4merge \$PWD/\$BASE \$PWD/\$REMOTE \$PWD/\$LOCAL \$PWD/\$MERGED"

$ git config --global mergetool.p4mergetool.trustExitCode false

$ git config --global mergetool.keepBackup false

A sample .gitconfig file:

[merge]
    tool = Kaleidoscope
[mergetool "p4mergetool"]
    cmd = " /Applications/p4merge.app/Contents/Resources/launchp4merge $PWD/$BASE $PWD/$REMOTE $PWD/$LOCAL $PWD/$MERGED"
    keepBackup = false

{% capture slide %}

Refspecs

{% endcapture %}

Git Refspec Documentation