GitExamples

[TOC]

移除某文件的版本控制

还没有加到版本控制中:

  • 还没有git add

    • .gitignore中添加

  • 已经git add

    • git rm -r --cached文件

    • .gitignore中添加

已经加到版本控制中

  • git rm -r --cached文件

  • .gitignore中添加

  • 最后git commit -m提交.gitignore

查看历史提交

bovenson@MBP:~/Git/notes$ git log
commit 27a5edf3be21260ae58db052daece60c43f2fd03 (HEAD -> master, origin/master, origin/HEAD, mayun/master)
Author: bovenson <[email protected]>
Date:   Fri Dec 1 21:58:06 2017 +0800

    auto commit

commit 95bd6dd8068b02cb64fe0692630b79f21cd35ee6
Author: bovenson <[email protected]>
Date:   Fri Dec 1 09:05:45 2017 +0800

    auto commit

commit f4d00e5f9f56064422976f3bad3ce5c72d4f3e6d
Author: bovenson <[email protected]>
Date:   Thu Nov 30 18:19:21 2017 +0800

    auto commit

commit deebf122267a72ad889cedbacb8dee5efba15a2e
Author: bovenson <[email protected]>
Date:   Wed Nov 29 20:04:40 2017 +0800

    auto commit
...

从历史版本检出某个文件

从历史版本检出某个文件夹

如果提示找不到路径, 注意执行命令的当前路径, 如果给出的相对于相对于仓库根目录的相对路径, 要在仓库根目录下执行命令.

查看两个版本之间的差别

查看两个版本某个文件/文件夹的差异

回退到某一版本

删除某一commit

检出远程分支为本地分支

Unstage all staged file

Remove file or directory from repository

删除文件

配置当前工程用户信息

最后更新于

这有帮助吗?