您的位置:首页 > 其它

Git常用命令

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

git checkout -b <branchname> //创建并切换到分支
//以上等于
git branch <branchname> //创建分支
git checkout <branchname>//切换到该分支

git branch //查看分支信息
git branch -d <branchname>  //删除分支
git merge <branchname>  //合并某分支到当前分支
git merge –no-ff  -m "some words"  <branchname>   //禁用“Fast forward”模式下合并分支并记录消息
git stash //储存当前工作环境
git stash list   //查看储存了哪些工作环境
git stash apply   //恢复之前储存的环境
git remote    //查看远程库信息
git remote -v  // 查看远程库详细信息
git push origin master  //推送master分支到远程库
git checkout  –b <branchname> origin/<branchname> //把远程的origin的dev分支到本地
git pull   //获得最新提交


另外shell中还有如下命令很重要:
mkdir
rm
cat
cd
ls
pwd
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: