![]() |
![]()
| ![]() |
![]()
NAMEgit-absorb - Automatically absorb staged changes into your current branch SYNOPSISgit absorb [FLAGS] [OPTIONS] DESCRIPTIONYou have a feature branch with a few commits. Your teammate reviewed the branch and pointed out a few bugs. You have fixes for the bugs, but you don’t want to shove them all into an opaque commit that says fixes, because you believe in atomic commits. Instead of manually finding commit SHAs for git commit --fixup, or running a manual interactive rebase, do this: $ git add $FILES_YOU_FIXED $ git absorb --and-rebase git absorb will automatically identify which commits are safe to modify, and which indexed changes belong to each of those commits. It will then write fixup! commits for each of those changes. You can check its output manually if you don’t trust it, and then fold the fixups into your feature branch with git’s built-in autosquash functionality. FLAGS-r, --and-rebase Run rebase if successful. See also the REBASE_OPTIONS
below.
-n, --dry-run Don’t make any actual changes
--force-author Generate fixups to commits not made by you
--force-detach Generate fixups even when on a non-branch (detached)
HEAD
-F, --one-fixup-per-commit Only generate one fixup per commit
-f, --force Skip all safety checks as if all --force-* flags were
given. See those flags to understand the full effect of supplying
--force.
-w, --whole-file Match the first commit touching the same file as the
current hunk. Use this with care!
-h, --help Prints help information
-V, --version Prints version information
-v, --verbose Display more output
OPTIONS-b <base>, --base <base> Use this commit as the base of the absorb stack
-m <MESSAGE>, --message <MESSAGE> A simple commit message body that will be used for
all generated fixup commits.
--gen-completions <SHELL> Generate completions [possible values: bash, fish,
nushell, zsh, powershell, elvish]
— <REBASE_OPTIONS> Options to pass to git rebase after generating commits.
Must be the last arguments and the -- must be present. Only valid when
--and-rebase is used.
USAGE 1.git add any changes that you want to absorb. By
design, git absorb will only consider content in the git index.
2.git absorb. This will create a sequence of commits on
HEAD. Each commit will have a fixup! message indicating the message (if
unique) or SHA of the commit it should be squashed into.
3.If you are satisfied with the output, git rebase -i
--autosquash to squash the fixup! commits into their predecessors. You can set
the GIT_SEQUENCE_EDITOR environment variable if you don’t need to edit
the rebase TODO file.
4.If you are not satisfied (or if something bad
happened), git reset --soft PRE_ABSORB_HEAD to the pre-absorption commit to
recover your old state. (You can also find the commit in question with git
reflog.) And if you think git absorb is at fault, please file an issue.
CONFIGURATIONSTACK SIZEWhen run without --base, git-absorb will only search for candidate commits to fixup within a certain range (by default 10). If you get an error like this: WARN stack limit reached, limit: 10 edit your local or global .gitconfig and add the following section: [absorb] ONE FIXUP PER FIXABLE COMMITBy default, git-absorb will generate separate fixup commits for every absorbable hunk. To always generate only 1 fixup commit for all hunks that absorb into the same commit, edit your local or global .gitconfig and add the following section: [absorb] AUTO-STAGE ALL CHANGES IF NOTHING STAGEDBy default, git-absorb will only consider files that you’ve staged to the index via git add. However, sometimes one wants to try and absorb from all changes, which would require to stage them first via git add .. To avoid this extra step, set [absorb] which tells git-absorb, when no changes are staged, to auto-stage them all, create fixup commits where possible, and unstage remaining changes from the index. FIXUP TARGET ALWAYS SHABy default, git-absorb will create fixup commits with their messages pointing to the target commit’s summary, and if there are duplicate summaries, will fall back to pointing to the target’s SHA. Instead, can always point to the target’s SHA via: [absorb] GENERATE FIXUPS FOR COMMITS NOT AUTHORED BY YOUBy default, git-absorb will only generate fixup commits for commits that were authored by you. To always generate fixups for any author’s commits, edit your local or global .gitconfig and add the following section: [absorb] GENERATE FIXUPS ON DETACHED HEADBy default, git-absorb will not generate fixup commits when HEAD is not a branch ("is detached"). To always generate fixups on detached HEADs, edit your local or global .gitconfig and add the following section: [absorb] GITHUB PROJECThttps://github.com/tummychow/git-absorb AUTHORStephen Jung <tummychow511@gmail.com>
|