Git复习(十二)之命令专场

命令

git init -> 初始化一个git仓库

git clone -> 克隆一个本地库

git pull -> 拉取服务器最新代码

git fetch –p -> 强行拉取远程代码覆盖本地(同步远程,不止是代码)

git add -> 添加到git仓库

git commit –m “” -> 提交到git仓库

git push -> 将本地代码推送到远程

git push --tags -> 把本地新增的所有tag推到远程

git push origin <tagname> -> 推送标签到远程

git push origin --tags -> 推送所有未推送到远程的标签

git push –u origin master -> 把本地仓库内容推送到远程(将本地master分支内容推送到远程master分支,并本地的master分支和远程的master分支关联起来)

git tag -> 查看所有标签

git tag <name> -> 打一个新标签

git tag <name> <commit id> -> 给指定的版本打标签

git tag –a “name” –m “descript” -> 创建带有说明的标签

git tag –d <tagname> -> 删除本地标签(还未推送到远程)

git show <tagname> -> 查看标签信息

git status -> 查看当前状态

git branch -> 查看分支

git branch –a -> 查看所有分支

git branch -r -> 查看所有分支

git branch <name> -> 创建分支

git branch -d <name> -> 删除分支(分支已经合并)

git branch –D <name> -> 删除没有被合并的分支

git checkout <name> -> 切换分支

git checkout –b <name> -> 创建一个新分支并切换过去

git checkout -- <file> -> 丢弃工作区的修改

git checkout -- . -> 丢弃对所有内容的修改

git checkout . -> 还原本地修改(“.”:前有空格)

git merge <name> -> 合并某分支到当前分支(快速合并)

git merge --no-ff –m “提交说明” dev -> 合并某分支到当前分支(取消快速合并)

git diff -> 查看做了什么修改

git diff HEAD – readme.txt -> 查看工作区和最新版本库的区别

git remote add <name>(origin) <url>(git仓库的名字) -> 关联一个远程库(把本地仓库和远程仓库关联起来)

git remote -> 查看远程仓库信息

git remote –v -> 查看远程仓库地址{2个地址{fetch}{push}}

git log -> 查看提交历史(包含commit id、作者、日期、提交说明)

git log --pretty=oneline -> 查看提交历史并在一行显示,是一种简洁的形式(只包含commit id、提交说明)

git log --graph -> 查看分支合并图

git stash -> 存储工作现场

git stash list -> 查看stash内容

git stash pop -> 恢复工作现场并删除stash内容

git stash apply <stash> -> 恢复工作现场但没有删除stash内容

git stash drop -> 除stash内容

git reset HEAD <file> -> 把暂存区的修改撤销掉(丢弃对暂存区的修改),重新放回工作区(此时已经add到了暂存区)

git reset --hard HEAD^ -> 回退到上一个版本(已经commit)

git reset --hard commit_id -> 回退到某个具体的版本(知道版本号)(已经commit)

git reset . -> 从地暂存区释放(“.”:前有空格)

git reflog -> 查看命令历史(记录每一次命令,找回被删除的版本)

git rm <file> -> 从版本库删除文件

git rebase -> 把本地未push的分叉提交历史整理成直线

git config --global user.name

git config --global user.email

git config --global color.ui true

git config --global alias.ci commit

简写

alias -> 展示各种缩写

缩写:g     ->  完整版:git 

缩写:gss  ->  完整版:git status -s

缩写:ga    ->  完整版:git add

缩写:gcmsg  ->  完整版:git commit -m

缩写:gp   ->  完整版:git push

缩写:glg  ->  完整版:git log --stat   查看历史包含增删改的信息

缩写:gco ->  完整版:git checkout 

缩写:gcm ->  完整版:git checkout master

缩写:gcb ->  完整版:git checkout -b

缩写:gd   ->  完整版:git diff

缩写:gb    ->  完整版:git branch

缩写:gbD   ->  完整版:git branch -D

缩写:gbd   ->  完整版:git branch -d

缩写:gd --cached   ->  完整版:git diff --cached 对比当前的文件和前一个commit的更改

缩写:gco commitid 文件名   ->  完整版:git checkout commitid  xxx 将xxx文件checkout出来,也就是将xxx文件的内容替换为commitid版本号该文件的内容

参考

git log 详解

 

posted @ 2019-08-16 16:37  坤嬷嬷  阅读(303)  评论(0编辑  收藏  举报