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?
Ask HN: What is your Git commit/push flow?
131–140 of 201 posts
Re: Ask HN: What is your Git commit/push flow?
#132Here'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…
Re: Ask HN: What is your Git commit/push flow?
#133 git commit --amend --no-edit
oftenonce a piece of functionality is working, edit the commit so it makes sense
start new commit and work on next piece of functionality, repeat
clean commit history not just for me but for my coworkers who will benefit from seeing a cohesive commit diff
Re: Ask HN: What is your Git commit/push flow?
#134I push at least once a day
Re: Ask HN: What is your Git commit/push flow?
#135The commit all the time is a waste of time for me - my IDE (intellij) has excellent local history.
Re: Ask HN: What is your Git commit/push flow?
#136I like to git commit --amend --no-edit often once a piece of functionality is working, edit the commit so it makes sense start new commit and work on next piece of functionality, repeat clean commit history not just for me but for my coworkers who will benefit from seeing a cohesive commit diff
Re: Ask HN: What is your Git commit/push flow?
#137Earlier quoted context omitted.
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 use the interactive flag on git add for this. It lets you add parts of a file, commit, and then do it all again. I want to say it's git add -i, but I'm not 100% on that. My fingers just do the right thing when I want it to happen.
Re: Ask HN: What is your Git commit/push flow?
#138>I also push often because I'm forever aware disks can fail. In the 20+ years that I've been using computers, and ≈15 or so that I've been writing software, I've never experienced a drive failure.
Re: Ask HN: What is your Git commit/push flow?
#139Re: Ask HN: What is your Git commit/push flow?
#140If I need to hack on a task and I know I'm the only person that's going to work on the branch I amend changes to my commit basically constantly. The only reason I might not is if I want multiple commits on the branch to make review simpler for others.
```
git fetch && git checkout main
git branch feature/JIRA-###/words-describing-it
git checkout feature/JIRA-###/words-describing-it
git add .
git commit -m "JIRA-###: words / description"
git push -u origin feature/JIRA-###/words- describing-it
git add .
git amend
git push -f
```
`git amend` is an alias in my ~/.gitconfig
```
#cat ~/.gitconfig
[alias]
amend = commit --amend --no-edit
```So most of my commits I just amend the first commit I made, force push, review CI build results, rinse repeat until it's ready for review.
Simplest thing that works when it's just my own work on a branch. I'll also do a rebase pre PR review if need be.
```
git fetch && git rebase -i origin/main
git status
git add
git rebase --continue
git push -f
```