git实用但不常用的命令(持续更新)

这篇文章用来记录工作中会需要但又不像push,pull这么常用好记的命令:

查看git用户名和邮箱地址命令:
$ git config user.name
$ git config user.email
修改用户名和邮箱地址:
$ git config–global user.name “username”
$ git config–global user.email “email”

撤销commit(实用)
git reset --soft/mixed/hard(代表三种模式,取其一就行) HEAD~1

如果进行了两次commit都想撤回,可以使用HEAD~2
soft:不删除工作空间代码,撤销commit,不撤销git add
mixed:不删除工作空间代码,撤销commit,撤销git add
hard:删除工作空间代码,撤销commit,撤销git add

如果commit注释写错了,只想改一下注释:
git commit --amend

发布了2 篇原创文章 · 获赞 0 · 访问量 8

猜你喜欢

转载自blog.csdn.net/ljg_12345/article/details/104379586