-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
git rebase & change commits history #9
Labels
Comments
git rebase变基 修改前面多次的 commit 历史记录 $ git rebase -i HEAD~3
# 交互式
# -i, --interactive let the user edit the list of commits to rebase
# 修改前面多次的(3次 ) commit 历史记录
$ git rebase -i HEAD~3
$ git rebase -h
usage: git rebase [-i] [options] [--exec <cmd>] [--onto <newbase> | --keep-base] [<upstream> [<branch>]]
or: git rebase [-i] [options] [--exec <cmd>] [--onto <newbase>] --root [<branch>]
or: git rebase --continue | --abort | --skip | --edit-todo
--onto <revision> rebase onto given branch instead of upstream
--keep-base use the merge-base of upstream and branch as the current base
--no-verify allow pre-rebase hook to run
-q, --quiet be quiet. implies --no-stat
-v, --verbose display a diffstat of what changed upstream
-n, --no-stat do not show diffstat of what changed upstream
--signoff add a Signed-off-by trailer to each commit
--committer-date-is-author-date
make committer date match author date
--reset-author-date ignore author date and use current date
-C <n> passed to 'git apply'
--ignore-whitespace ignore changes in whitespace
--whitespace <action>
passed to 'git apply'
-f, --force-rebase cherry-pick all commits, even if unchanged
--no-ff cherry-pick all commits, even if unchanged
--continue continue
--skip skip current patch and continue
--abort abort and check out the original branch
--quit abort but keep HEAD where it is
--edit-todo edit the todo list during an interactive rebase
--show-current-patch show the patch file being applied or merged
--apply use apply strategies to rebase
-m, --merge use merging strategies to rebase
-i, --interactive let the user edit the list of commits to rebase
--rerere-autoupdate update the index with reused conflict resolution if possible
--empty <{drop,keep,ask}>
how to handle commits that become empty
--autosquash move commits that begin with squash!/fixup! under -i
-S, --gpg-sign[=<key-id>]
GPG-sign commits
--autostash automatically stash/stash pop before and after
-x, --exec <exec> add exec lines after each commit of the editable list
-r, --rebase-merges[=<mode>]
try to rebase merges instead of skipping them
--fork-point use 'merge-base --fork-point' to refine upstream
-s, --strategy <strategy>
use the given merge strategy
-X, --strategy-option <option>
pass the argument through to the merge strategy
--root rebase all reachable commits up to the root(s)
--reschedule-failed-exec
automatically re-schedule any `exec` that fails
--reapply-cherry-picks
apply all changes, even those already present upstream
➜ git git:(test) git commit
$ git commit -m "描述信息"
# Commit message options
# m, --message <message> commit message
# -e, --edit force edit of commit
$ git commit -e
# 仅修改 commit message ✅
$ git commit --amend
# 仅修改上一次的 commit 历史记录 文件内容 ✅
# Commit contents options
# --amend amend previous commit
$ git commit -h
usage: git commit [<options>] [--] <pathspec>...
-q, --quiet suppress summary after successful commit
-v, --verbose show diff in commit message template
Commit message options
-F, --file <file> read message from file
--author <author> override author for commit
--date <date> override date for commit
-m, --message <message>
commit message
-c, --reedit-message <commit>
reuse and edit message from specified commit
-C, --reuse-message <commit>
reuse message from specified commit
--fixup [(amend|reword):]commit
use autosquash formatted message to fixup or amend/reword specified commit
--squash <commit> use autosquash formatted message to squash specified commit
--reset-author the commit is authored by me now (used with -C/-c/--amend)
--trailer <trailer> add custom trailer(s)
-s, --signoff add a Signed-off-by trailer
-t, --template <file>
use specified template file
-e, --edit force edit of commit
--cleanup <mode> how to strip spaces and #comments from message
--status include status in commit message template
-S, --gpg-sign[=<key-id>]
GPG sign commit
Commit contents options
-a, --all commit all changed files
-i, --include add specified files to index for commit
--interactive interactively add files
-p, --patch interactively add changes
-o, --only commit only specified files
-n, --no-verify bypass pre-commit and commit-msg hooks
--dry-run show what would be committed
--short show status concisely
--branch show branch information
--ahead-behind compute full ahead/behind values
--porcelain machine-readable output
--long show status in long format (default)
-z, --null terminate entries with NUL
--amend amend previous commit
--no-post-rewrite bypass post-rewrite hook
-u, --untracked-files[=<mode>]
show untracked files, optional modes: all, normal, no. (Default: all)
--pathspec-from-file <file>
read pathspec from file
--pathspec-file-nul with --pathspec-from-file, pathspec elements are separated with NUL character
➜ git git:(test)
|
https://stackoverflow.com/questions/5189560/how-do-i-squash-my-last-n-commits-together
$ git merge --squash
# --squash create a single commit instead of doing a merge $ git merge -h
usage: git merge [<options>] [<commit>...]
or: git merge --abort
or: git merge --continue
-n do not show a diffstat at the end of the merge
--stat show a diffstat at the end of the merge
--summary (synonym to --stat)
--log[=<n>] add (at most <n>) entries from shortlog to merge commit message
--squash create a single commit instead of doing a merge
--commit perform a commit if the merge succeeds (default)
-e, --edit edit message before committing
--cleanup <mode> how to strip spaces and #comments from message
--ff allow fast-forward (default)
--ff-only abort if fast-forward is not possible
--rerere-autoupdate update the index with reused conflict resolution if possible
--verify-signatures verify that the named commit has a valid GPG signature
-s, --strategy <strategy>
merge strategy to use
-X, --strategy-option <option=value>
option for selected merge strategy
-m, --message <message>
merge commit message (for a non-fast-forward merge)
-F, --file <path> read message from file
-v, --verbose be more verbose
-q, --quiet be more quiet
--abort abort the current in-progress merge
--quit --abort but leave index and working tree alone
--continue continue the current in-progress merge
--allow-unrelated-histories
allow merging unrelated histories
--progress force progress reporting
-S, --gpg-sign[=<key-id>]
GPG sign commit
--autostash automatically stash/stash pop before and after
--overwrite-ignore update ignored files (default)
--signoff add a Signed-off-by trailer
--no-verify bypass pre-merge-commit and commit-msg hooks
➜ git git:(test)
$ git reset -h
usage: git reset [--mixed | --soft | --hard | --merge | --keep] [-q] [<commit>]
or: git reset [-q] [<tree-ish>] [--] <pathspec>...
or: git reset [-q] [--pathspec-from-file [--pathspec-file-nul]] [<tree-ish>]
or: git reset --patch [<tree-ish>] [--] [<pathspec>...]
-q, --quiet be quiet, only report errors
--mixed reset HEAD and index
--soft reset only HEAD
--hard reset HEAD, index and working tree
--merge reset HEAD, index and working tree
--keep reset HEAD but keep local changes
--recurse-submodules[=<reset>]
control recursive updating of submodules
-p, --patch select hunks interactively
-N, --intent-to-add record only the fact that removed paths will be added later
--pathspec-from-file <file>
read pathspec from file
--pathspec-file-nul with --pathspec-from-file, pathspec elements are separated with NUL character
➜ git git:(test)
|
xgqfrms
added
git rebase
git rebase
git squash
git squash
git amend
git amend
图解 git
图解 git
labels
Oct 29, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
git rebase & change commits history
The text was updated successfully, but these errors were encountered: