News for hackers. Stuff that matters.
Re:Git Tricks: Avoiding merge when dealing with remote confl... by rinchik on Monday October 21, 2019 @07:46PM (#21318846)
Rebase isn't really a trick though.. is it?

It just a normal workflow and, sometimes, housekeeping in your small "feature" branch.

Re:Git Tricks: Avoiding merge when dealing with remote confl... by rumanator on Tuesday October 22, 2019 @03:35AM (#21321150)
Rebase os also a good way to wreack havoc in a repository, both local and remote.
Re:Git Tricks: Avoiding merge when dealing with remote confl... by chopin on Tuesday October 22, 2019 @08:36AM (#21322880)
Not in remote if you disallow force-push. For local I agree. For hairy rebases I normally set a marker tag (easier than to comb through the reflog). Then it is easy to reset the branch to its initial irrespective of what you've done.
Re:Git Tricks: Avoiding merge when dealing with remote confl... by mcv on Tuesday October 22, 2019 @10:03AM (#21323678)
Quite the opposite, sometimes rebasing means you need to force-push, and not doing so wreaks havoc.

Imagine I'm working on my own feature branch, pushing regularly to remote. I make my pull request to develop, but develop is ahead of me and my pull request can't be merged. So I pull develop, rebase my own local commits on top of that, and push the result in my feature branch to remote, which contains some of my old, un-rebased commits. The push is refused, and instead either git or intelliJ automatically pulls from the remote feature branch into my local branch, merging with no problem, so it can be pushed again.

It works, but not all my commits occur two times in the history, and that's bad.

I suspect it's not git doing this but IntelliJ, but it's a popular IDE, so this can easily happen to anyone if you're accidentally rebasing commits you already pushed.

Force pushing prevents the problem, but you're probably better off not rebasing in the first place. Don't change history that also exists in another location.