Skip to content

Instantly share code, notes, and snippets.

@destenson
Last active August 21, 2016 10:12
Show Gist options
  • Save destenson/58fa28b9075196f416de43d42dbca105 to your computer and use it in GitHub Desktop.
Save destenson/58fa28b9075196f416de43d42dbca105 to your computer and use it in GitHub Desktop.
How to commit to git

To really use the power of git, the maintainer/development team should follow these instructions:

After making several changes including several features that you want to check into git:

  • commit them all at once using stash as the commit message
  • Rename the current branch stash
  • Then branch the previous commit once for each "feature" or series of commits dependent upon each other, then on each new branch:
  • cherry pick from the stash, but don't commit yet
  • instead, curate the commit into just the code you want, deleting and staging files as necessary for the feature
  • then commit it to the appropriate branch (if it asks to save a stash or discard it before switching, discard it, we've already saved our own stash)
  • Once that's finished, branch the original commit as master
  • Then for each new branch:
  • merge the branch 'as commit' into master
  • optionally, modify the commit message message to be more precise, concise, or descriptive
  • Once all branches are merged back into master, rebase stash onto master
  • After working through merge conflicts, stash should be essentially the same as master
  • If it is not, either:
  • cherry pick and commit what's left back into master, or
  • if it deserves more than one commit, create a branch following the same procedure as before
  • Once stash is essentially the same as master, the stash branch can be deleted

EOF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment