Earlier quoted context omitted.
There is a hierarchy to these things: - Person who destroys git history - Person who hates destroying git history - Person who knows how to recover "destroyed" history - Person who knows how to truly destroy git history
> - Person who knows how to truly destroy git history … tell me more!
Hitting every branch on the way down
91–100 of 144 posts
Re: Hitting every branch on the way down
#92Earlier quoted context omitted.
Commits are for saving your current work. Commit early, commit often. Just clean them up when you're done! Don't push half-baked work on other people! You waste their compute cycles needlessly, from now until the end of time.
I sometimes wish git supported hierarchical commits. I.e., git can retain two representations of a sequence of commits: the original sequence, and also a larger commit that (a) produces the exact same code change as the sequence, and (b) has its own commit message.
Re: Hitting every branch on the way down
#93Earlier quoted context omitted.
I wouldn't consider rebasing your own local commits on top of a more recent remote master to be messing with history in any meaningful way, and that's the most useful method of rebasing.
Rebasing unpushed commits is ok. But I have yet to see a workflow that provides good enough guardrails to make it something you can do safely.
And only on working branches. I do this every single day.
Re: Hitting every branch on the way down
#94Earlier quoted context omitted.
I don't want to have to go back and forth with someone to pull their branch. I want to just be able to pull anything they've pushed.
Isn't "protect your main branch" still the answer to this? Your two feature branches would be unprotected so you can merge away if you like. When one of you wants to commit something to master, that's when you'd check for dodgy merges. Also, "git cherry-pick" is a good alternative to merging for this use case.
- Having a developer on your team that rebases their own feature branch
- Then tries to "git push", only for it to be rejected since a force push is required
- Then performs a "git push --force", which will force-push all of their local branches, including feature branches from other developers that they may have checked out previously
Our team uses merges because they are safe from this kind of problem, although a rebase workflow would have cleaner history. I wish that "git push --force" would not push all branches by default, and just fail unless a (remote, branch) pair or --all is given.
Re: Hitting every branch on the way down
#95Earlier quoted context omitted.
And the best answer is: "Why do you do useless commits?". With `git amend` and `git fixup` you can arrange your commits to be clean, properly documented and self explanatory (and maybe atomic but that's a little harder). It takes a little time but it is hugely beneficial to code reviews and bug investigation.
Some people however see using features like amend, squash, and force push as potentially destructive actions in the hands of a novice, which can lead to loss of not only the author's work but also other people's. Using merge almost never results in any sort of loss and is easier to work with for those who still don't quite understand the risks.
Nobody should be able to force-push to master (or any public branch) except on specific occasion. In that case, someone is authorized, performs their specific action and then get de-authorized.
This is pretty basic.
Re: Hitting every branch on the way down
#96I wont claim to understand C and the reason why is better than “”. I assume it is. But the fact that a merge can have arbitrary changes in it always bothers me! This is a case for rebase over merge if there are conflicts. You could have a merge of 2 empty repo parents where the result is the complete source of the latest version of Kubernetes!
One idiot with rebase destroys history with no trace. I worked with such an idiot in a parallel team. I can't say how many weeks of work randomly got destroyed by said idiot. I hate rebase on shared code I don't care how clean jt looks. Don't mess with history.
Re: Hitting every branch on the way down
#97Earlier quoted context omitted.
Rebasing unpushed commits is ok. But I have yet to see a workflow that provides good enough guardrails to make it something you can do safely.
--force-with-lease And only on working branches. I do this every single day.
Re: Hitting every branch on the way down
#98Earlier quoted context omitted.
Right but assuming I have a branch that's diverged from theirs I have to do a fiddly git rebase --onto and likely resolve the same conflicts again.
If you find yourself fixing the same rebase conflicts over and over again, because you for some reason need to work on conflicting changes simultaneously (which is of course best avoided for other reasons), use "git rerere".
Re: Hitting every branch on the way down
#99Earlier quoted context omitted.
Some people however see using features like amend, squash, and force push as potentially destructive actions in the hands of a novice, which can lead to loss of not only the author's work but also other people's. Using merge almost never results in any sort of loss and is easier to work with for those who still don't quite understand the risks.
"Force push" is something that should be restricted to a very few senior people anyway; once you do that, you can't rewrite shared history any more and a lot of the worries go away.