这里记录一些 Git 在 Windows 操作系统下使用方法:
安装完毕后,先让Git 记录自己的名字:
$ git config --global user.name "Your Name" $ git config --global user.email "email@example.com"
一、 创建版本库
在要创建版本库的文件夹空白处 右键打开菜单 选择 "Git Bash Here" 选项来打开 类似 "命令行"的窗口
确定好目录后 就可以利用 git init 把目录变成仓库
$ git init
Initialized empty Git repository in xxxxxxxxx
二、添加文件到仓库
命令 $git add <file> 添加到仓库, 然后 $git commit 提交到仓库
$git add index.php
$git commit -m "添加修改注释" //注释部分很重要 必须
三、查看状态
$git status //查看结果
$git diff //查看修改部分
四、版本回退
$git log //查看历史记录
$git reset --hard HEAD~1 //会退到历史上上1个版本
$git reset --hard xxxxxxid //会退到ID为 xxxx 的版本
$git reflog //获取 Git 上操作记录
五、撤销修改
$git checkout -- file //撤销修改 -- 前后都有空格 误删文件也可以回复
$git rm index.php //删除文件的话 得运行一遍
原文:http://www.cnblogs.com/linjilei/p/5096163.html