4 ms·
“rebase” is just “pull before push”, right? While I have no opinion on git, I can’t abide by all the precious chaotic mutant misuse, like git-flow. I’d happil
by specialist 9y ago
“rebase” is just “pull before push”, right?
While I have no opinion on git, I can’t abide by all the precious chaotic mutant misuse, like git-flow.
I’d happily accept a subset of primitives, if only to disallow bad ideas. Kinda like Git vs SVN, C/C++ vs Java, flamethrower vs peanut butter.
- joesb 9y ago"rebase" is not just "pull before push", though. It's pull then rewrite all your personal commits to be based on the latest tip from that pull.
- fulafel 9y agoRebase is a controversial history altering operation and makes it easy to paint yourself into a corner and get weird error messages or wrong results. Its very different from pull/merge.
- y2kenny 9y agoHistory altering is only controversial on things that are published. There is nothing wrong with reordering, combining or splitting your local commits to give more clarity to what you are doing. Keeping this in mine will give you the freedom to commit frequently. This confusion happens because many popular SCMs historically have the "commit" and "push" operation in a single step. Git keep them separate.
- fulafel 9y agoThere is no tracking by git on what is published, so it's easy to make the mistake of rebasing things that are published and shared by others. Then you will have a bad time later when you try to sync with others, possibly days later.
- y2kenny 9y agoUm... git kind of does with remote tracking branches. You can also make it very obvious by your workflow? If you use local feature branches (which you should for juggling between development tasks, etc.), what you are working on vs what's upstreamed should be pretty clear. Sounds like you are not using local branches. Not using local branch is another confusion caused by the perspective of historical/traditional SCMs (people thinking branches are the domain of a centralized server and are outside of their control.)
- fulafel 9y agoOften you want to push changes to a remote, but not yet merge or PR them to upstream. Keeping "local feature branches" just on your dev machine is bad for many many reasons: - you want to encourage low barrier cooperation in your team -> sharing changes - you want changes to the CI pipeline early so the potentially slow testing machinery works in parallel with the developer - you want to keep the team up to date on what changes you make - you don't want to lose work if the machine/OS dies, or the developer leaves/becomes sick/goes on a 4 week vacation during which they forget their disk crypto password So, in practice you can try to use rebase opportunistically, when out of chance your WIP work is still unpushed because the change was only made very recently. This is error prone. Or you can rebase published branches explicitly, by destroying the original branches in the PR merge phase. But all this is big bother if the purpouse is to just beautify history and at the same time hide the real trial and error that went into making the changes.
- TomK32 9y agoI LOVE rebase but when I run into merge conflicts I rather `rebase --abort` and leave that merge commit as it is. But those instances are rare and having a merged branch's commits nice and compact in the log makes me happy every time.
- aidenn0 9y agoRebase is "rewind local changes" "pull" "replay local chances" Basically it makes it so that all of the local-only commits are sequenced after any remote changes that you have not seen yet. [edit] YZF is correct. In the context of pulling (i.e. "git pull --rebase") my description is correct. However in general rebasing branch X to Y that diverge from commit C is: rewind branch Y to commit C; call the old tip of Y Y' play all commits from C -> X on Y play all commits from C -> Y' to branch Y.
- YZF 9y agoYou can rebase between two local branches. The rebase operation has nothing to do with pull or remote vs. local.
- aidenn0 9y agoYes. I thought we were in the context of git pull --rebase...
- e12e 9y ago"pull" might be the first thing I'd throw out, if thought there was any hope of fixing git ux. Then add a working merge --dry-run #do i have conflicts?.
- aidenn0 9y agoI think a default of --ff-only would be fine for pull. This is great for when I'm merely a consumer of a project, and will never silently perform a merge or rebase.
- specialist 9y agoThanks (all) for the clarifications. When explaining to others, I should probably say 'pull, reapply, then push'. Perhaps 'rebranch' is a better word choice than 'rebase', to conceptually more closely match what's actually happening under the hood.
- YZF 9y agorebase is simply(tm) replaying a sequence of commits (or diffs or patches for that matter) over some arbitrary base, hence re-base ...
- TomK32 9y agorebase can do a lot more. Try `git rebase -i` to squash smaller commits, edit the commit msg, or even drop a commit before you push it to your colleagues. Last time our devop did 20 commits to get something on elasticbeanstalk right, I squashed it all into just one clean commit that got merged into master branch. It will help you to commit more often without worry until the moment you have to hand in your work.