Skip to content

Instantly share code, notes, and snippets.

@coopermaruyama
Last active August 29, 2015 14:25
Show Gist options
  • Save coopermaruyama/1372aee5bfcbb92f3e8f to your computer and use it in GitHub Desktop.
Save coopermaruyama/1372aee5bfcbb92f3e8f to your computer and use it in GitHub Desktop.
Git Notes
# ---------------------------------------------------
# Correct workflow when working with forked upstreams.
# ---------------------------------------------------
git fetch origin --prune
# If you haven't made any local changes:
git checkout branch-name
git merge --ff-only origin/branch-name
# If you have local changes, you'll get this error: fatal: Not possible to fast-forward, aborting.
# Rebase, but without creating an additional commit per merge.
git rebase --preserve-merges origin/branch-name
# ----------------------------------
# Using subtree instead of submodules
# -----------------------------------
# - When committing, separate subtree-related commits from your main repo commits (not required but ideal).
# add the remote
git remote add -f cool-plugin-remote https://github.com/user/some-plugin.git
# pull, suqashing the entire history
git subtree add --prefix vendor/cool-plugin cool-plugin-remotr master --squash
# At a later date, pull in new changes
git fetch cool-plugin master
git subtree pull --prefix vendor/cool-plugin cool-plugin-remote master --squash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment