5.8k sao GitHub và vẫn tăng — tummychow/git-absorb là dự án Rust mà TopGit đang theo dõi trên nền tảng. git commit --fixup, but automatic
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
This is a port of Facebook's hg absorb, which I first read about on mozilla.dev.version-control:
Facebook demoed hg absorb which is probably the coolest workflow enhancement I've seen to version control in years. Essentially, when your working directory has uncommitted changes on top of draft changesets, you can run hg absorb and the uncommitted modifications are automagically folded ("absorbed") into the appropriate draft ancestor changesets. This is essentially doing hg histedit + "roll" actions without having to make a commit or manually make history modification rules. The command essentially looks at the lines that were modified, finds a changeset modifying those lines, and amends that changeset to include your uncommitted changes. If the changes can't be made without conflicts, they remain uncommitted. This workflow is insanely useful for things like applying review feedback. You just make file changes, run hg absorb and the mapping of changes to commits sorts itself out. It is magical.
Elevator Pitch
You 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 staged changes belong to each of those commits. It will then write fixup! commits for each of those changes.
With the --and-rebase flag, these fixup commits will be automatically integrated into the corresponding ones. Alternatively, 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:
git add $FILES_YOU_FIXED
git absorb
git log # check the auto-generated fixup commits
git rebase -i --autosquash master
Installing
The easiest way to install git absorb is to download an artifact from the latest tagged release. Artifacts are available for Windows, MacOS, and Linux (built on Ubuntu with statically linked libgit2). If you need a commit that hasn't been released yet, check the latest CI artifact or file an issue.
Alternatively, git absorb is available in the following system package managers:
Repository
Command
Arch Linux
pacman -S git-absorb
Debian
apt install git-absorb
DPorts
pkg install git-absorb
Fedora
dnf install git-absorb
Flox
flox install git-absorb
FreeBSD Ports
pkg install git-absorb
Homebrew and Linuxbrew
brew install git-absorb
MacPorts
sudo port install git-absorb
nixpkgs stable and unstable
nix-env -iA nixpkgs.git-absorb
openSUSE
zypper install git-absorb
Ubuntu
apt install git-absorb
Void Linux
xbps-install -S git-absorb
GNU Guix
guix install git-absorb
Windows Package Manager
winget install tummychow.git-absorb
Compiling from Source
You will need the following:
cargo
Then cargo install git-absorb. Make sure that $CARGO_HOME/bin is on your $PATH so that git can find the command. ($CARGO_HOME defaults to ~/.cargo.)
Note that git absorb does not use the system libgit2. This means you do not need to have libgit2 installed to build or run it. However, this does mean you have to be able to build libgit2. (Due to recent changes in the git2 crate, CMake is no longer needed to build it.)
Note: cargo install does not currently know how to install manpages (cargo#2729), so if you use cargo for installation then git absorb --help will not work. There are two manual workarounds, assuming your system has a ~/.local/share/man/man1 directory that man --path knows about:
build the man page from source and copy
This requires that the a2x tool be installed on your system.
cd ./Documentation
make
mv git-absorb.1 ~/.local/share/man/man1
download a recently-built man page
find a recent build as in Installing above
download the git-absorb.1 file and unzip
move it to ~/.local/share/man/man1
Usage
git add any changes that you want to absorb. By design, git absorb will only consider content in the git index (staging area).
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.
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.
If you are not satisfied (or if something bad happened), git reset --soft PRE_ABSORB_HEAD will reset to the pre-absorption commit and 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.
How it works (roughly)
git absorb works by checking if two patches P1 and P2 commute, that is, if applying P1 before P2 gives the same result as applying P2 before P1.
git absorb considers a range of commits ending at HEAD. The first commit can be specified explicitly with --base <ref>. By default the last 10 commits will be considered (see STACK SIZE in git-absorb.adoc for how to change this).
For each hunk in the index, git absorb will check if that hunk commutes with the last commit, then the one before that, etc. When it finds a commit that does not commute with the hunk, it infers that this is the right parent commit for this change, and the hunk is turned into a fixup commit. If the hunk commutes with all commits in the range, it means we have not found a suitable parent commit for this change; a warning is displayed, and this hunk remains uncommitted in the index.
Documentation
For additional information about git-absorb, including all arguments and configuration options, see Documentation/git-absorb.adoc,
or the git-absorb manual page.
TODO
implement remote default branch check
stop using failure::err_msg and ensure all error output is actionable by the user
slightly more log output in the success case
more tests (esp main module and integration tests)
document stack and commute details
more commutation cases (esp copy/rename detection)
don't load all hunks in memory simultaneously because they could be huge
implement some kind of index locking to protect against concurrent modifications
tummychow/git-absorb thuộc nhóm Developer Tools trên TopGit, cùng 2 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về tummychow/git-absorb ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/tummychow/git-absorb là nguồn chính thức.
tummychow/git-absorb có phải mã nguồn mở không?
Có — tummychow/git-absorb phát hành theo license BSD-3-Clause, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/tummychow/git-absorb.
tummychow/git-absorb là gì?
tummychow/git-absorb (tummychow/git-absorb) là dự án Rust trên GitHub. Theo mô tả gốc: git commit --fixup, but automatic
tummychow/git-absorb so với các dự án Developer Tools khác thế nào?
tummychow/git-absorb được TopGit xếp vào nhóm Developer Tools, với 5.8k sao GitHub và viết bằng Rust. Xem trang chủ đề Developer Tools trên TopGit để so sánh với các dự án tương tự theo số sao và mức độ hoạt động.
Vì sao tummychow/git-absorb được xếp vào nhóm Developer Tools?
TopGit xếp tummychow/git-absorb vào nhóm Developer Tools dựa trên GitHub topics và mô tả của repo (gắn thẻ: "git", "rebase"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
Muốn nghe thêm một ý kiến về git-absorb?
Hỏi một AI đọc được trang này — một cú bấm là có ngay nhận định về git-absorb.