Git/提交修改:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
第13行: 第13行:


=== commit ===
=== commit ===
== commit ==
=== rebase ===
=== reset ===
<div class="pageBoxGreen"><code>^</code> 表示前一次。<code>^^^^</code> 等价于 <code>~4</code>。<br>
{{hcdiff|head=|output=<syntaxhighlight lang="bash">
git reset fb69f9d^^^^</syntaxhighlight>|output2=<syntaxhighlight lang="bash">
git reset fb69f9d~4
</syntaxhighlight>}}</div>
取消最后一次 commit。
{{shc|<syntaxhighlight lang="bash">
git reset fb69f9d^
# or
git reset master^
# or
git reset HEAD^</syntaxhighlight>|$|/home/kangkk}}
回退到指定 commit
{{shc|<syntaxhighlight lang="bash">
git reset fb69f9d</syntaxhighlight>|$|/home/kangkk}}
==== --mixed ====
==== soft ====
==== hard ====
=== --amend ===
=== 追加文件到 commit ===
==== reset ====
删除最后一次 commit,重新 commit。
==== --amend --no-edit ====
将文件并入最后一次 commit。使用 <code>--no-edit</code> 标识不进行编辑 commit 信息。
{{shc|<syntaxhighlight lang="bash">
git add src/a.js && \
git commit --amend --no-edit</syntaxhighlight>|$|/home/kangkk}}
== 命令合并 ==
== 命令合并 ==
现在我们将文件 a.js 加入暂存区并提交 commit 信息。
现在我们将文件 a.js 加入暂存区并提交 commit 信息。