Git

作者: JackyBA | 来源:发表于2017-02-23 19:13 被阅读0次

ref: 工作区和暂存区

工作区 暂存区 版本库

Git远程库版本回滚

撤销修改:

  • 小结
    场景1:当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时,用命令 $ git checkout -- file

    场景2:当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令 $ git reset HEAD file
    ,就回到了场景1,第二步按场景1操作。
    场景3:已经提交了不合适的修改到版本库时,想要撤销本次提交,参考版本回退一节,不过前提是没有推送到远程库。
命令 含义
$ git config --global user.name "Your Name"
$ git config --global user.email "email@example.com"
$ git checkout -- <file> 撤销工作区的修改
$ git reset HEAD <file> 撤销(unstage) 暂存区的修改, 重新放回工作区
$ git reset --hard <commit_id>
$ git log 提交(Commit) 历史
$ git reflog 命令历史
$ git config --global alias.logx "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" 配置查看提交历史命令别名
$ git stash branch <branch_name> 从储藏中创建分支

取消储藏(Un-applying a Stash)

$ git config --global alias.stash-unapply '!git stash show -p | git apply -R' ```

```shell
$ git config --global alias.logx "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit" 

相关文章

网友评论

    本文标题:Git

    本文链接:https://www.haomeiwen.com/subject/wsvxvttx.html