Try to keep your master branch clean and create branches. The feature-branch-workflow is a good compromise between all novel as well as experienced git users.
- I need a new feature in myproject:
git checkout -b fea/new-cool-feature
- I need to fix a bug:
git checkout -b fix/weird-error
- I need to do a quick workaround for a bug:
git checkout -b hot/weird-error
- fea (feature)
- fix (bug fix)
- hot (workaround)
- Keep your first commit line short
- use imperative update instead of updated
- use familiar keywords such as:
add, update, remove, fix, refactor
master *---*---*---*
\
my branch *---*---*
think, before you pull changes from origin or you're getting into trouble.
stop using the standardized merge strategy for git pull
master *---*---*---*---*
\ /
my branch *---*---*
if you need an update from master or any other branch, try to rebase your branch instead of merging. try to keep your branch history separated from master, so others can easily follow one straight line of commits.
master *---*---*---*
\
my branch --> *---*---*
So, if you want to pull, try
git pull --rebase
if you want to update your work with stuff from master
git fetch -a && git rebase master
if you're running into thousand of merge conflicts, try to merge, but do not merge in case of laziness!
if all hope is gone, use cherry pick as your last hope to get back to work. but use with wisdom! this is only for advanced users: [further reading: cherry-pick vs. merge workflow][http://stackoverflow.com/questions/1241720/git-cherry-pick-vs-merge-workflow]
if you try to push your rebased branch, your remote will reject your command, because you changed the history of your branch. you need to do a force push and this is not exactly brilliant. if other people work on that branch too, inform them about your rebase and check, before pushing. be patient to your programmer mates!