Git Commands

强颜欢笑 提交于 2019-11-30 05:45:52

Git Commands

​ 基本操作

Command Explanation
git config --global user.name "" 设置用户姓名
git config --global user.email "" 设置用户邮箱
git init 在当前目录创建仓库
git clone 将远程的仓库克隆到本地
git add . 将当前目录下的所有代码添加到暂存区
git commit -m "" 提交暂存区内容,并设置注释

​ 比对

Command Explanation
git diff 比对当下的内容和暂存区内容,显示差别
git diff HEAD 比对当下的内容和最近一次提交的内容,显示差别
git diff HEAD^ 比对当下的内容和倒数第二次提交的内容,显示差别
git diff HEAD^ HEAD 比对最近两次提交,显示区别

​ 历史

Command Explanation
git log 打印提交历史
git log --oneline 打印为单行
git log --all 打印所有记录
git log --graph 打印历史示意图

​ 分支

Command Explanation
git branch [分支] 无分支,创建分支;有分支,打印所有的分支
git checkout 切换至分支
git checkout -b 创建并切换至该分支
git merge 将分支与当前分支合并

​ 远程

Command Explanation
git pull 拉取远程仓库
git push 推送至远程仓库的分支下
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!