Git常用命令

git init -------------创建Git 仓库

git config --global user.name tom -------------设置全局的用户名

git config --global user.email tom@qq.com -------------设置全局的email

git add [file name] -------------追踪该文件并添加到暂存区

git commit -m'说明信息' -------------将暂存区的内容提交到本地库

git status -------------查看工作的、缓存区的状态

git log -------------查看版本记录

git log --pretty=oneline -------------相对简单的查看版本记录

git reflog -------------版本操作记录

git reset --hard HEAD^ -------------回退版本上个版本(一个 ^ 代表后退一个版本)

git reset --hard HEAD~1 -------------回退版本上个版本 (按照索引)

git reset --hard 版本序号 -------------回退指定的版本

git checkout -- 文件名 -------------丢弃工作区的改动

git reset HEAD 文件名 -------------取消暂存

git diff HEAD -- 文件名 -------------对比当前工作区与某个版本的不同

git diff HEAD HEAD^ -- 文件名 -------------对比两个版本的不同

git rm 文件名 -------------删除一个文件(可以通过恢复上个版本找回 )

git branch -------------查看当前分支

git checkout -b 分支名 -------------创建并且切换到分支

git branch -d 分支名 -------------删除指定分支

git checkout 分支名 -------------切换到指定分支

git merge 分支名 -------------快速合并分支

git merge --no-ff -m'说明' 分支名 -------------快速合并分支,禁用fast forward模式

git stash -------------暂时保存当前工作现场

git stash list -------------列出保存的工作现场

git stash pop -------------恢复保存的工作现场

ssh-keygen -t rsa -C "邮箱"

git push origin 分支名 -------------将分支推送到远程

git pull orgin 分支名 -------------拉取远程分支的代码

posted @ 2020-10-10 23:11  深陈  阅读(109)  评论(0)    收藏  举报