getsolus / help-center-docs

Solus's Help Center documentation as well as previous User Guide.
https://help.getsol.us
GNU General Public License v2.0
57 stars 83 forks source link

Additions to git tips & tricks - using fixup commits to ammend an existing pull request #573

Open TraceyC77 opened 1 month ago

TraceyC77 commented 1 month ago

Assuming you're in a package foo's directory and you just made a change that you want to amend/fixup to the previous commit (e.g. forgot to bump release number, last rebuild before submission that changed the pspec build date), you can run the following to create a fixup commit that's associated with the last commit performed to this package:

# fixup commit      last commit in directory
git commit --fixup $(git log -1 --format="%h" -- .)

For example, if the last commit for in this package's directory is foo: update to 1.4, then your fixup commit would be something like

fixup! foo: update to 1.4

and when you run git rebase --autosquash (or choose fixup manually in git rebase -i), your fixup commit would be amended to its previous commit. You can keep stacking up fixup commits and they will all get amended in the creation order to the initial target commit.