您的位置:首页 > 其它

git常用命令

2015-10-14 01:27 369 查看

添加远程仓库

git remote add origin <url ssh or https>


建立本地分支与远程的关系

git branch --set-upstream master origin/master


查看状态

git status


查看当前分支

git branch


查看修改

git diff <file>
gti diff HEAD --<fiel>


查看日志

git log


版本回退

git reset --hard HEAD^ or commit id


记录每一次命令

git  reflog


撤销修改(工作区与版本区的修改)

git checkout -- <file>


撤销暂存区(把提交到暂存区的修改返回到工作区 如果需要彻底的撤销修改 就用git checkout – 命令)

git reset HEAD <file>


删除文件

git rm <file>
git commit


删除文件夹

git rm <dir> -r
git commit


误删除文件恢复

git checkout -- <file>


创建分支

git branch <name>


切换分支

git checkout <name>


创建分支并切换

git checkout -d <name>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: