As git users, we know that we should "commit early, commit often." While this is a wonderful thing to do, it does mean that from time to time we ma...
For further actions, you may consider blocking this person and/or reporting abuse
Here are a few shortcuts in the same vein:
fixup with the default of HEAD:
fu = !bash -c 'git commit --fixup ${1:-HEAD}' -
Find the point of divergence of the current branch from another branch (default master), useful for the following trick:
diverges = !bash -c 'diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "${1:-master}") <(git rev-list --first-parent "${2:-HEAD}") | head -1' -
Finally, rebase with autosquash from the point of divergence from another branch (so that you don't have to count the commits):
ar = !bash -c 'git rebase --autosquash -i `git diverges ${1:-master}`'
This is great, thanks!
Nice article!
Note that you can also use
git config --global rebase.autosquash=true
so that you do not need to add the--autosquash
flag to all yourgit rebase
commands.Thanks!
That's true. Just make sure to add
--no-autosquash
to thegit mri
alias to get the same behavior.Cool tip!
Just to clarify, it's
git config --global rebase.autosquash true
; having the=
throws aninvalid key
error.I don't quite get why I wouldn't use the much simpler
git amend
(alias forgit commit --amend
) for the simple case of adding to the last commit and only do a rebase (remember no unstaged changes for that, may need to stash!) if I really need it.That's a matter of personal preference.
I like having the history of minor changes available. I usually only rebase before a
git push
, and by that time, I try not to have any uncommited changes in any case.I feel that the little extra typing (which can be saved using @freeatnet tip here) is worth it for the extra history and for editing previous commits.
Wow, this is great. I am going to immediately modify my workflow in this direction.
Woops, commented from the staff account. ¯_(ツ)_/¯
Yes, yes and a thousand times yes!
Developers need to learn to commit often and create small commits for their own safe and their mates.
So huge thank you for spreading the word :)
I also wrote an article on this subject few weeks ago: adopteungit.fr/en/methodology/2017...
Another alternative is
git rebase -i
and marking the "Added First Module" with "edit". Then make the change, add, commit and rebase --continueAlso a nice tip that usually goes along with
--fixup
is to find the commit with:/
i.e.git commit --fixup :/First
will find the last commit withFirst
in its message.Cool, haven't used fixup yet.
Just saying if you hate things because they hide history you should fight against rebase too
It's the hiding history while I work part that bothers me.
Thanks for the article, useful information.
But amend is not evil if you use it in right purposes.
ps: never used amend it fix the history, only for append changes on dev commit.