Comments (6)
https://github.com/web-full-stack/git/tree/test
from git.
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
修改
上一次
的 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://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
from git.
from git.
https://www.cnblogs.com/xgqfrms/p/16465388.html#5117980
git docs
https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History
https://git-scm.com/docs/git-rebase
https://git-scm.com/docs/git-commit
https://git-scm.com/docs/git-merge
https://git-scm.com/docs/git-reset
from git.
https://stackoverflow.com/questions/5189560/how-do-i-squash-my-last-n-commits-together
git merge --squash
???
git reset --soft HEAD~3
???
$ 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)
from git.
try
https://www.git-tower.com/learn/git/faq/git-squash
https://medium.com/open-devops-academy/a-git-crash-course-for-you-rewriting-the-history-8c4edba537e6
https://thoughtbot.com/blog/git-interactive-rebase-squash-amend-rewriting-history
???
https://gist.github.com/patik/b8a9dc5cd356f9f6f980
https://gist.github.com/Pk13055/c9167a6002ed07cda42c81ba47325b7e
from git.
Related Issues (6)
- GtiHub PR
- first PR HOT 2
- git squash PR HOT 1
- git rebase PR
- Sourcetree 教程 HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from git.