Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • When you do a git pull to get remote changes, if you have any local commits that haven't been pushed yet (wait, you're not working directly on master, are you?), specify --rebase (you can also make this the default option as explained in this article). This will modify the sequence of commits to your local repository so that your locally-committed changes appear after those you just pulled. Now when you push your changes, your fellow committers will just see an incremental set of changes with yours at the end, and it will make sense to them.
  • Always fast-forward your branch commits to master. Fast-forward just means putting your commits at the end of the latest existing commits on a branch. When you run git merge yourbranch, by default, git will attempt to do a fast-forward commit if possible. It's not possible if there are any changes in master that aren't already in your branch. In this case, before attempting to merge your changes into master, switch to your branch and type git rebase master. This will put all the new commits from master in your branch, behind your changes. Now it should be possible to fast-forward merge your branch into master by switching to master and typing git merge yourbranch
  • Note: It's possible, though not common, that a git pull --rebase or a git rebase master will fail due to a conflict. In that case, see this excellent article, which covers resolving rebase conflicts.

...