Git常用命令

 1 git init   //把这个目录变成git可以管理的仓库
 2 git add <filename>  //把该文件添加到暂存区
 3 git commit   //把所有暂存区文件提交到仓库
 4 git diff <filename>    //查看修改前后内容
 5 git log  //log
 6 git reset  –hard HEAD^  //退回上一个版本
 7 git reset  –hard HEAD^^   //退回上上个版本
 8 git reset  –hard HEAD~100    //退回前100个版本
 9 git reset  –hard 6fcfc89  //退回6fcfc89版本
10 git status   //查看状态
11 git checkout -- <filename>   //恢复该文件
12 git remote add origin <url>   //设置远程仓库
13 git clone <url>      //克隆远程仓库

14 git checkout -b <branchname> //创建并切换到分支 15 //以上等于 16 git branch <branchname> //创建分支 17 git checkout <branchname>//切换到该分支 19 git branch //查看分支信息 20 git branch -d <branchname> //删除分支 21 git merge <branchname> //合并某分支到当前分支 22 git merge –no-ff -m "some words" <branchname> //禁用“Fast forward”模式下合并分支并记录消息 23 git stash //储存当前工作环境 24 git stash list //查看储存了哪些工作环境 25 git stash apply //恢复之前储存的环境 26 git remote //查看远程库信息 27 git remote -v // 查看远程库详细信息 28 git push origin master //推送master分支到远程库 29 git checkout –b <branchname> origin/<branchname> //把远程的origin的dev分支到本地 30 git pull //获得最新提交 31

另外shell中还有如下命令很重要:
mkdir
rm
cat
cd
ls
pwd

posted @ 2016-01-25 00:46  韬神  阅读(162)  评论(0编辑  收藏  举报