Skip to content
This repository has been archived by the owner on Jun 13, 2022. It is now read-only.

Latest commit

 

History

History
executable file
·
68 lines (47 loc) · 1.17 KB

2019-01-08-Git知识-reset.md

File metadata and controls

executable file
·
68 lines (47 loc) · 1.17 KB
layout title subtitle author date header-img catalog tags
post
Git知识-reset,gitignore,stach
重置暂存区
Kingtous
2019-01-08 12:41:34 -0800
img/post-bg-unix-linux.jpg
true
Git

##Git Reset

  • 重置暂存区
    • 工作区->暂存区->版本库
git reset HEAD .
git reset HEAD foo.txt

第一个参数:重置的版本号

第二个参数:指定要被重置的文件

  • 重置分支指针
git reset --hard [commit] #--hard确保工作区和暂存区也被恢复成提交时的状态 

Git .gitignore

  • 忽略部分文件

可以使用通配符(* ,&)

#Simple Example
dir/
dir
*.bak
!k.bak #!配合上一行表示,除k.bak之外的以bak为拓展名的都被git忽略
  • 注意

    • 只能影响当前没有交给git管理的文件

    • 若要影响已经交给git管理的文件

      • git update-index --assume-unchanged

Git stash

  • 没做完一件事,但是要修复别的bug,可以使用stash将修改保存在本地
git stash     #将工作区和暂存区的修改保存在一个储藏栈中 stash stack
git stash pop #恢复位于栈顶的被储藏修改
git list #查看