Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git for solo developer: merge vs rebase [duplicate]

Tags:

git

I'm a solo developer and am just getting into using Git with private BitBucket repositories. The one thing I'm not clear on is Merge versus Rebase.

I frequently switch between desktop and laptop and have been using BB to have access to the latest code on either platform. I've been using rebase when I load the latest committed code, because I think it essentially clears out everything on that platform (desktop or laptop) and ensures I have the identical code as committed to BB. Is that correct? When should I use merge to such an action?

like image 514
mraviator Avatar asked Jul 27 '13 11:07

mraviator


1 Answers

rebase and merge are different kind of strategies for bringing your branch uptodate with another branch. rebase changes the history to the point where both branches started diverging. merge on the other hand, does not alter history and might create a new commit to show the merge of two branches.

See also this document on rebase vs merge. Bottomline: use rebase for unpushed changes to create neat history; otherwise use merge.

Update: Linus wrote about this in 2009, see his advice on git rebase and merge. Bottom line: rebase only your own private stuff, with caution. If your commits have been pushed, no more rebasing.

like image 75
Bouke Avatar answered Oct 12 '22 23:10

Bouke