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.

Summary

Details

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

Summary

Further reading

Validated Build Promotions with Git, GitHub, and Jenkins

Git and GitHub Workflows at the Utah JUG

Summary

$ 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]

Further reading

More examples

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

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

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

Fixing Branches

To change which base a branch is placed upon:

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

Further reading

Maintaining, customizing remotes

# Discard remote local branches
# not present on upstream
$ git fetch --prune

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

Customizing Interaction

$ git fetch [repo-url] [source]:[destination]
$ git config --add remote.[upstream].fetch "+refs/pull/*/head:refs/remotes/[upstream]/pull/*"
Dependencies with subtree

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]
$ git read-tree
  --prefix=[directory]/
    -u [branch]
$ git merge --squash
  -s subtree [branch]

By commit message

Adds a rigorously formatted text block to commit messages:

Summary

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
Git Refspec Documentation