We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
# 姓用户名 $ git config --global user.name "Your Name" # 用户邮箱 $ git config --global user.email "[email protected]" # 设置换行符均不转换 $ git config --global core.autocrlf false # 设置大小写敏感 git config --global core.ignorecase false
branch -d
git branch -d <branch_name>
如果我们在试图删除一个分支时自己还没转移到另外的分支上(或者被删除的分支还有文件没被提交),Git就会给出一个警告,并拒绝改删除操作。 如果坚持删除改分支的话,就需要在命令中使用 -D 选项
-D
git branch -D <branch_name>
git reset --soft HEAD^
注意,仅仅是撤回commit操作,你写的代码依然保留 HEAD^是上一个版本,也可以写成HEAD~1
git reset的几个参数如下:
--mixed
意思是:不删除工作空间改动代码,撤销commit,并且撤销git add .操作,这个为默认参数,git reset --mixed HEAD^ 和 git reset HEAD^ 效果是一样的。
git add .
git reset --mixed HEAD^
git reset HEAD^
--soft
不删除工作空间改动代码,撤销commit,不撤销git add .
--hard
删除工作空间改动代码,撤销commit,撤销git add .
注意:完成这个操作后,就恢复到了上一次的commit状态
git stash # 查询所有暂存 git stash list # 取出暂存 git stash pop # 取出某个暂存(一定要加双引号) git stash pop "stash@{0}" # 删除某个暂存 git stash drop "stash@{0}" 这是删除第一个队列
git pull origin dev
如果在远程版本库上删除了某一分支,该命令并不会删除本地的远程追踪分支
git remote prune origin --dry-run
git remote prune origin
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Git 命令常用速查表
git配置规范
删除分支/恢复分支
如果需要删除的分支不是当前正在打开的分支,使用
branch -d
直接删除如果我们在试图删除一个分支时自己还没转移到另外的分支上(或者被删除的分支还有文件没被提交),Git就会给出一个警告,并拒绝改删除操作。
如果坚持删除改分支的话,就需要在命令中使用
-D
选项撤销
commit之后,想撤销commit
git reset的几个参数如下:
--mixed
意思是:不删除工作空间改动代码,撤销commit,并且撤销
git add .
操作,这个为默认参数,git reset --mixed HEAD^
和git reset HEAD^
效果是一样的。--soft
不删除工作空间改动代码,撤销commit,不撤销
git add .
--hard
删除工作空间改动代码,撤销commit,撤销
git add .
暂存
远程操作
指定从某个远程分支(如dev)更新代码到当前分支
Git 清理无效的远程追踪分支
如果在远程版本库上删除了某一分支,该命令并不会删除本地的远程追踪分支
The text was updated successfully, but these errors were encountered: