1,安装好git之后,设置名称和邮箱
$ git config --global user.name "Your Name"
$ git config --global user.email “email@example.com”
2,创建本地仓库【先创建一个目录】
mkdir pro [在Windows系统中目录名称不要使用中文]
git init [目录变仓库]
vim test.txt [编写文件]
git add test.txt 向本地仓库中增加文件
git commit -m "add test.txt" 【提交到版本库中{本地库}】
git status 查看当前状态
git diff test.txt 查看文件被具体修改的内容
git log 查看日志,修改的版本
git log --pretty=oneline 【把日志一个版本显示在一行】
git reset --hard head^ 回退到上一个版本 上上个head^^ HEAD~1000
git reset --hard 【commit_id】 版本返回到任何一个commit-id的版本
git reflog 用来记录你每一次执行的命令
先在github上创建一个远程库"Pratice"。
git remote add pratice http://hjj/Pratice.git 添加远程库
git branch 查看本地分支
git branch -r 查看远程分支
git remote -v 查看远程仓库信息
git commit -a 把索引区的所有都提交到本地库中
git add -a 把所有的都加进索引区中
vim .gitignore 忽略提交的项
git checkout [name] 切换分支
git branch [name] ----注意新分支创建后不会自动切换为当前分支
PS:“git commit”只负责把暂存区的修改提交了
例子:
$ git add file1.php
$ git add file2.php
$ git add file3.php
$ git commit –m “add file1.php file2.php file3.php”