Skip to end of metadata
Go to start of metadata

Do's

I candy for developers

please do not only stupidly pull and merge as you like

Pull Fast-Forward instead of simple pull or rebase if you only want to update your local branch

Using git pull --ff-only has several advantages:

  • it doesn't destroy any local merges if already existing ahead the remote (git pull --rebase does)
  • it preserves the timeline as straight as possible (only moves the branch pointer, denies update if you have diverged changes)
  • it allows you to keep local changes in your working tree unless it conflicts to the pull

have a look at my puffpu and purpur advice.

 

Sure: if you already have local commits, you'll need a rebase to keep on track of the lane. But you must not do this, if you have local merges. Then: reset, re-do merge after pull or pull with merge. A rebase will prune your merge and will rebase the merged branch!

Don't

use git pull --rebase until you know what you do

most time, you will need git pull --ff-only

^^ see above

Force push

This will overwrite the remote branch with your local branch (history) and will therfor "delete" all commits that are not yet merged in your branch!

So: NEVER DO A FORCE PUSH UNLESS YOU KNOW WHAT YOU'RE DOING!

*BEFORE*                                    *AFTER*

origin/master                               origin/master && master/local HEAD
o ---------- B                         
| 
|  o --------- c' {master (local/HEAD)}     o -- c'
o -| ------- A                              |
|  o --------- b'                           o -- b'
|  |                                        |
|  o --------- a'                           o -- a'
| /                                         |
|/                                          |
+ ---------- bp                             o -- bp
  • No labels