Git 命令

在使用 Git 的过程中用到的一些命令,可能包含一些平时不常用的命令。

[TOC]

分支重命名

本地分支重命名

git branch -m <old_name> <new_name>

远程分支重命名

删除远程分支

git push origin :<remote_branch_name>

推送本地分支

git push origin <local_branch_name>:<remote_branch_name>

合并同一分支的 Commit

查看 Log

git log --pretty=oneline
git_log

合并最近三次的提交

git_rebase

修改提交方式

origin
new

命令说明

重新修改 Commit 信息

将会使用红框内的 commit 作为 Title。

modify_commit

重新查看 Log

git_log2git_log2

其他 rebase 命令

撤销 Git 操作

查看刷新日志(reflog)

git_reflog

还原

查看 Commit Log

git_log3

Git 免输用户名和密码

SSH 协议

通过 SSH 协议和配置 Key,将公钥放置到 github 服务端。

HTTPS 协议

永久有效

保存有效期

merge 合并

no fast forward

所有 commit 信息都会保留

squash

所有 commit 合并成一个

Last updated