Live data from Hacker News

Ask HN: What is your Git commit/push flow?

news.ycombinator.com

41–50 of 201 posts

Re: Ask HN: What is your Git commit/push flow?

#43
I commit often (as long as it compiles, pass the linter, and fast unit tests if there exist), then I rewrite the history. If I work alone on the feature (which is most case) I also push quite often on a private branch (mostly for backup, and for running the CI). If needed, I also rewrite the history of my private branch and `push -f` (even though this isn't ideal...).

My PRs are clean, each commit pass the CI and is its own thing.

Re: Ask HN: What is your Git commit/push flow?

#46
post #9

Here's how I address this problem. When I'm developing, but before I create a PR, I'll create a bunch of stream-of-consciousness commits. This is stuff like "Fix typo" or "Minor formatting changes" mixed in with actual functional changes. Right before I create the PR, or push up a shared branch, I do an interactive rebase (git rebase -i). This allows me to organize my commits. I can squash commits, amend commits, mov…

The only problem I have with this workflow in the command line is that I would like to be able to split changes to the same file across multiple commits. I think some GUI tools enable this, anyone know about it?

Re: Ask HN: What is your Git commit/push flow?

#47
have you looked into squash commit merge.

Basically you do the same workflow as you are doing now, just squash it to a single commit so that wherever is your last commit stays.

if needed you can go to your branch for history

https://stackoverflow.com/questions/5308816/how-can-i-merge-...

Re: Ask HN: What is your Git commit/push flow?

#48
Messy WIP commits that are reorganized to cleaner commits later, like most others have said.

However, instead of rebasing, I often git reset to the beginning and recreate the commits from scratch, using partial file commits (or staged hunks). IDEs/editors like VS Code make it really easy to stage an individual part of a file for the commit. The CLI way (git add -p) has always been pretty confusing to me.

Re: Ask HN: What is your Git commit/push flow?

#49
post #9

Here's how I address this problem. When I'm developing, but before I create a PR, I'll create a bunch of stream-of-consciousness commits. This is stuff like "Fix typo" or "Minor formatting changes" mixed in with actual functional changes. Right before I create the PR, or push up a shared branch, I do an interactive rebase (git rebase -i). This allows me to organize my commits. I can squash commits, amend commits, mov…

The only problem I have with this workflow in the command line is that I would like to be able to split changes to the same file across multiple commits. I think some GUI tools enable this, anyone know about it?

When you're doing your interactive rebase, find the commit you'd like to split - choose "edit" for that one. Then when you reach that point, you can do `git reset HEAD^1` to bring those changes back onto your staging stack, and make as many commits as you need.

Re: Ask HN: What is your Git commit/push flow?

#50
post #9

Here's how I address this problem. When I'm developing, but before I create a PR, I'll create a bunch of stream-of-consciousness commits. This is stuff like "Fix typo" or "Minor formatting changes" mixed in with actual functional changes. Right before I create the PR, or push up a shared branch, I do an interactive rebase (git rebase -i). This allows me to organize my commits. I can squash commits, amend commits, mov…

The only problem I have with this workflow in the command line is that I would like to be able to split changes to the same file across multiple commits. I think some GUI tools enable this, anyone know about it?

I do this via git add -p which breaks your changeset down into atomic patches that you can either add, skip or delete before making a commit. You can turn one file change into many commits this way, if need be.
Post reply on HN