3 ms·
If I switch to a previous commit to amend it, then I would temporarily lose all the other changes I made, and means I can't easily run tests on that particular
by ArchOversight 4y ago
If I switch to a previous commit to amend it, then I would temporarily lose all the other changes I made, and means I can't easily run tests on that particular commit to validate nothing else broke.
It sounds like I would need to:
- switch
- amend the commit
- restack?
- switch back to the HEAD?
Fold based upon the documentation seems to move older commits into the current commit? vs the other way around? https://sapling-scm.com/docs/commands/fold https://sapling-scm.com/docs/commands/fold
This doesn't seem analogous to git rebase --autosquash which merges the mixup into the old commit.
- arxanas 4y agoYes, in my preferred workflow, I usually create a temporary commit and then switch away. Sapling also has `sl shelve` as `git stash`. If you want to run tests on commits without checking them out, you might want to try my `git test` command: https://github.com/arxanas/git-branchless/discussions/643 https://github.com/arxanas/git-branchless/discussions/643 You can use `sl fold --exact` to combine arbitrary commits without including the current one. (To be honest, I just always used `sl histedit`.)
- mitrandir77 4y ago`sl histedit` is very similar to `git rebase -i` if you're famiilar with that interface which works just fine. Other commands useful for amending changes to previous commits: * `sl goto --merge <hash>` - if theres no conflicts you can just switch commits with pending changes and those pending changes would be applied on top of other commit. If there are conflicts this command would fail https://sapling-scm.com/docs/commands/goto https://sapling-scm.com/docs/commands/goto * `sl absorb` - this automagically finds the last commit that touched the lines that are pending and amends that commit with them https://sapling-scm.com/docs/commands/absorb https://sapling-scm.com/docs/commands/absorb
- tchebb 4y ago`sl absorb` can turn that workflow into a single command in many cases: it automatically looks at what hunks you've changed and tries to propagate them back to earlier commits in the stack that touched those same hunks. It's not perfect, but in my experience using this at Meta, it does what you want 90% of the time.