Created
December 5, 2014 21:56
-
-
Save jpbetz/29471e66cf9b7fe4cff5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Suggested configurations (these are executable commands): | |
# Sets your master branch to rebase instead of merge when you "git pull" | |
git config branch.master.rebase true | |
# When you create/checkout a new remote branch, automatically | |
# sets it as described above. This could also be set to "always" to include | |
# local branches as well | |
git config branch.autosetuprebase remote | |
# When merging TO your master branch, allow only fast-forward merges. | |
git config branch.master.mergeoptions --ff-only | |
# As an alternative to "mergeoptions", Git version 1.7.6 and above support | |
# the following, which applies to all branches, not just master, but note our RPMs | |
# have git 1.7.1. | |
git config merge.ff only | |
Suggested workflow, after incorporating above config, based on committing to gitli and using ReviewBoard: | |
# Starting from master, this creates a new branch AND switches to it | |
git checkout -b topic/my-feature | |
# work work work | |
git commit | |
# work work work | |
git commit | |
# ready to post a ReviewBoard | |
git review | |
# Incorporate feedback | |
git commit | |
git review dcommit # This adds "R=XXXX" to the commit log | |
# optional step to clean up, squash commits, generally get your branch ready and make | |
# your patch look "super neat" | |
git rebase -i master | |
git checkout master | |
# Update to latest | |
git pull | |
#now merge your branch | |
git merge topic/my-feature | |
# If the merge worked, you're ready to push | |
git push | |
# and then you're done. | |
# If the merge didn't work ("unable to fast forward"), you need to rebase your feature branch | |
git checkout topic/my-feature | |
git rebase master | |
# May have to deal with conflicts when you rebase | |
git checkout master | |
git merge topic/my-feature | |
# merge should have succeeded this time (and print a message about "fast forwarding") | |
git push | |
# to reset local 'master' to the same on the remote master ('origin/master') | |
# (this can be useful if everything was ready for git push, but got stalled and now the dev branch needs to be rebased again and remerged) | |
git checkout master | |
git reset --hard origin/master | |
To squash commits when on master use: | |
git rebase -i HEAD~X | |
where X is the number of commits to squash together | |
then replace pick with 's' for the 2nd entry on to get them squashed up with the first entry |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment