Skip to content

Instantly share code, notes, and snippets.

@m-renaud
Last active November 4, 2016 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m-renaud/1b2926c91f36274e1ebb1023066c8f7c to your computer and use it in GitHub Desktop.
Save m-renaud/1b2926c91f36274e1ebb1023066c8f7c to your computer and use it in GitHub Desktop.
Git commands for building generated files on another branch and pulling them in temporarily for a build
#!/bin/bash
# Save the current branch.
previous_branch=`git rev-parse --abbrev-ref HEAD`
# Switch to generated code branch and pull in any changes from the working branch.
git checkout generated-code
git merge --no-edit $previous_branch
# <Build generated files>
# Run whatever code gen commands here you need to.
# Commit all generated files.
git add --all
git commit -m "Generated code"
# Switch to the working branch and merge in generated files, but don't commit them.
git checkout $previous_branch
git merge --no-commit --no-ff generated-code
# <Build binary>
# Run whatever build commands here you need to.
# Discard generated files pulled in by the merge.
git merge --abort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment