News for hackers. Stuff that matters.
Re:Please use git pull --rebase by wanderr on Monday April 29, 2013 @10:06PM (#5630056)
if you want to do a merge commit sometimes, but pull --rebase most of the time, why not make pull --rebase the default, and do a fetch && merge when that's what you want?
Re:Please use git pull --rebase by Zombieball on Monday April 29, 2013 @10:52PM (#5630190)
Because what if you 'already' created a merge?

Example: I am working on a local branch feature/xyz. I decide I am done my work and merge feature/xyz -> master. I get ready to push and realize I am 5 commits behind origin/master. How do I fetch them now?

If you use git --rebase it will clobber your feature branch merge commit. On the other hand if you do a fetch & merge this also probably is not what you want (you will have a merge-commit on top of your merge commit, dawg). git rebase -p is probably the best option in this scenario.

Re:Please use git pull --rebase by erso on Tuesday April 30, 2013 @12:16AM (#5630392)
I would ignore everything base698 says below.

In this case, you have a merge commit from a branch on to master, which would look like:

    A-B(master)----F (merge commit)
        \         /
         C-D-----E (topicA)
Once you find out your master (B) is behind, because say there's G-H-I on origin, you'd want to rebase onto that. So you use the 3-argument form of git rebase --onto:

git rebase --onto origin/master C~1 E

Which would take C's old base, C~1 (B), and replace it with origin/master, but only up to E.

Or, if you still had the branch around that you merged into master (which you do, in many forms, including the reflog, even after you delete the branch).

git rebase --onto origin/master topicA

I wrote a blog post on the different uses of git rebase --onto: http://krishicks.com/blog/2012/05/28/git-rebase-onto/

Re:Please use git pull --rebase by Zombieball on Tuesday April 30, 2013 @09:28PM (#5635945)
Ah awesome, I love there are so many things to learn about git.

I knew about git rebase -p and its nuances, but haven't known about the --onto until now. The 3-argument form of git rebase --onto in your blog post was great, thanks!

Re:Please use git pull --rebase by base698 on Monday April 29, 2013 @11:42PM (#5630299)
git checkout -b branch_fix; # for safety

git reset --hard HEAD~1

git fetch;

git merge origin/master;

git push origin HEAD:master;

git push origin HEAD:old_branch;

Re:Please use git pull --rebase by nahname on Tuesday April 30, 2013 @10:20AM (#5632307)
For me, my alias 'git pr' is shorter than 'git pull'. For the person working with me, not being in a rebase when they didn't expect to be is also a boon.