Git笔记

由于经常忘记或需要查询 Git 命令,我打算在我的博客上整理一下。

汇总提交

用rebase -i可行

因为犯了个错误,提交了一个奇怪的内容,所以想把最近的两个提交整合起来。

$ git rebase -i HEAD~2

有多种不同的编辑器可供选择。

pick e8ccc98 Returning body only
pick 5c02485 fix slow FileUpload

# Rebase b4bf38e..5c02485 onto b4bf38e (2 commands)
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out

需要汇总的提交,请将 “pick” 修改为 “s”。结果可以通过 “git log” 进行确认。

我想修改提交信息。

如果想要修正前一个提交之外的稍早提交,可以使用git rebase -i HEAD~xx将特定的提交设置为”edit”。详细步骤可以参考这里。

    【備忘録】過去のコミットメッセージを変更する

删除 GitHub 上的分支

git push origin :branch

可以

git push origin branch

git 源 分支(本地):分支(远程)

因为这是意味着天空被推动。

$ git push origin :fix/slowbackend
Enter passphrase for key '/Users/ushio/.ssh/id_rsa': 
To github.com:Azure-Samples/customer-car-reviews.git
 - [deleted]         fix/slowbackend

    Githubのブランチ削除
bannerAds