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
- Integrity checking with
- GitHub Flow
- Compatibility with Pull Requests
- Long-term release support
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
- next (graduation from pu)
- pu (can be rebased)
- “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’.”
- Breaking features down into pieces
- Feedback early on Pull Requests
- @mentioning teams instead of individuals
- Continuous integration
- 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]
$ git cherry-pick [ref] $ git cherry-pick [ref1] [ref2] $ git branch --contains [noncherrypickedref] $ git cherry [upstreambranch] + bd650366fa8c39f03cfc9dd5290f60e7331a631d + ea62f9f6a7cef55a8a3028e617d28819408a63c4 + 874628c0e405390130d6457776273451bb66d3a8 + 046a9b8d0f2363361e45cfbc7e0f6d82968f2f9f + 315fe16408f9a9080527e00df3d9a8c1ba0dc97a
- 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>
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>
- Specification for retrieval and pushing
- Implied on fetch, pull, and push
- Altered by option switches like
- Stored in
- 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/*"
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]
By commit message
Adds a rigorously formatted text block to commit messages:
$ 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]>"
[diff] tool = p4merge [difftool "p4merge"] cmd = "/Applications/p4merge.app/Contents/Resources/launchp4merge $LOCAL $REMOTE" [difftool] prompt = false
$ 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
[merge] tool = Kaleidoscope [mergetool "p4mergetool"] cmd = " /Applications/p4merge.app/Contents/Resources/launchp4merge $PWD/$BASE $PWD/$REMOTE $PWD/$LOCAL $PWD/$MERGED" keepBackup = false