When multiple people work in the repo, I like Squash Merge in Github best because you can still do small commits in your feature branch, and when you merge, it generates a message from all commits messages (so there is still a trace of the process, but you can get rid of noise like "fixed a typo" with the benefit of hindsight) and history looks clean because it's merged as a single commit, no rebase footgun to worry…
Ask HN: What is your Git commit/push flow?
191–200 of 201 posts
Re: Ask HN: What is your Git commit/push flow?
#192When multiple people work in the repo, I like Squash Merge in Github best because you can still do small commits in your feature branch, and when you merge, it generates a message from all commits messages (so there is still a trace of the process, but you can get rid of noise like "fixed a typo" with the benefit of hindsight) and history looks clean because it's merged as a single commit, no rebase footgun to worry…
IMO this feature destroys the history the developer of the PR should have crafted carefully in the first place. With a squash merge you basically say "I don't give a f..." and remove all traceability from the PR, giving future developers potentially a big headache if they have to figure out why something was done. That's why I think squash merge should _never_ be used and is one of the very big anti-features of githu…
Re: Ask HN: What is your Git commit/push flow?
#193Re: Ask HN: What is your Git commit/push flow?
#194Here is my last five commit messages: "width*height is area", "fixing stuff i broke", "rm properties we dont need", "rm more useless attributes", "nicer figures". I do my best to keep the code base as clean as possible, but I couldn't care less about keeping the commit history pretty. Any time spent on prettifying git history is better spent on documenting the existing* code imo.
thank you for saying this. I'm always afraid to. revision control is a necessary safety net and facilitates discussion around changes (PRs). but people act as if the history is somehow _really really important_. I've seen someone post on HN, apparently seriously, that the history is more important than the source. I know a (potentially) really good developer that spends his time pulling in the recent patches and reor…
Re: Ask HN: What is your Git commit/push flow?
#195Earlier quoted context omitted.
Where is that? `git: 'gui' is not a git command. See 'git --help'.`
Got it, it is not built-in on all distros. Head to https://git-scm.com/docs/git-gui/ and https://github.com/prati0100/git-gui.git/ for more.
Re: Ask HN: What is your Git commit/push flow?
#196Earlier quoted context omitted.
thank you for saying this. I'm always afraid to. revision control is a necessary safety net and facilitates discussion around changes (PRs). but people act as if the history is somehow _really really important_. I've seen someone post on HN, apparently seriously, that the history is more important than the source. I know a (potentially) really good developer that spends his time pulling in the recent patches and reor…
Yeah I love picking my way thru junk commits/comments. You may as well not use VCS.
Re: Ask HN: What is your Git commit/push flow?
#197break down work to logically separated commits (one logical change at a time)
Fixups will eventually come when I change something that should be two commits down.
Make sure commit history makes sense to the reviewer
Explanatory commit messages: the why (this library did not fit the bill because ABC)
Open the PR
Re: Ask HN: What is your Git commit/push flow?
#198Re: Ask HN: What is your Git commit/push flow?
#199When I make some small change, it usually belongs to one of these topics. If it's the topmost commit, of course it can be combined into it with "git commit --amend --patch".
If the small change for one of the commits behind that one, then I make fixup commits with "git commit --fixup " or "git commit --fixup HEAD^^^" (as many carets as needed to refer to the commit I want).
If the little fix requires an addition to the commit message, then --squash instead of fixup.
These little fixup/squash commits can then be squashed into their target commits using "git rebase -i --autosquash".
That may be how some of your coworkers have clean histories.
In some environments, a change made up of numerous little commits like "fix typo" wouldn't pass peer review ; you're supposed to know ho to squash things together (but not too much so that topics get inappropriately combined).
Some shops have a policy that every commit has to build and possibly also pass the test cases. So you can't have an "oops, add missing semicolon" commit; its parent wouldn't build.
Commits should be like Stack Overflow answers: "is this useful to future visitors of this git history?"
Re: Ask HN: What is your Git commit/push flow?
#200Changes in the commit I'm pretty sure are going to be in the CR, staged changes I'm not sure about, and unstaged changes are "what I'm working on now". This way, "git diff" shows me what I'm working now (in case I'm interrupted) and "git show" shows me what I'm ready to push. If I want to sync with the trunk, I can do "git stash && git rebase && git stash pop", which mostly works well though sometimes there are merge conflicts that need resolving.
When I'm ready for review, I rebase my single commit, rerun any tests, do a git show and review the change top to bottom, then create the code review. Then I review the change again in the code review tool, where I quite frequently find silly things I missed like typos in documentation of print statements I forgot to remove. Then add reviewers.
The only downside to this I have is when I want to back out changes I've already committed. Git doesn't give you a great way to do this, but I've written an alias that can remove all changes to a file from the commit at the tip of the branch. I use this a couple of times a year.