【git】------git的基本命令 (此文章转载我的老师 Alley-巷子) 【git】------git的基本命令

 

001、初始化仓库,创建git仓库

git init

002、配置个人信息

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令
git config --global user.name <名字> --------->:配置用户名

git config --global user.email <邮箱>--------->:配置邮箱

git config --list --------->:查看配置信息

git config --global user.name  --------->:查看用户名

git config --global user.email --------> :查看邮箱
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

003、将工作区文件添加到缓存区

git add <文件名称>

004、查看文件状态

git status
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

005、将缓存区的文件添加到版本库

git commit -m "提交注释的说明"  --------->将缓存区的文件添加到版本库中 并加上注释
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

006、查看提交的版本日志

git log
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

007、查看文件最新改动的地方

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令
git diff <文件名称> --------->:查看工作区与暂存区文件的比较

git diff --cached ------------>:查看暂存区与版本库文件的比较

git diff master ------------>:查看工作区与版本区文件的比较

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

-开头的行,是只出现在源文件中的行

+开头的行,是只出现在目标文件中的行

空格开头的行,是源文件和目标文件中都出现的行

差异按照差异小结进行组织,每个差异小结的第一行都是定位语句,由@@开头,@@结尾

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

008、版本回退

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令
git reset --hard HEAD^ --------->回退到上一个版本

git reset --hard HEAD^^ --------->回退到上上个版本

git reset --hard HEAD~N --------->回退到第N个版本 N是一个整数

git reset --hard 版本号 --------->回退到指定版本
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

009、查看所有版本号

git reflog
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

 010、删除操作

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令
git rm <文件名称> --------->删除暂存区分支上的文件, 同时工作区也不需要这个文件

git rm -f <文件名称> --------->强制删除文件

git rm --cached <文件名称> --------->删除暂存区分支上的文件, 但本地又需要使用, 只是不希望这个文件被版本控制
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

011、git推送

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令
git push -u origin master --------->将文件上传到github上

git remote --------->查看远程仓库名称 默认 origin

git remote -v --------->查看当前的远程仓库名称和对应的地址

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

012、克隆

git clone <仓库地址>

013、创建分支

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令
git branch --------->:查看本地分支列表

git branch <分支名称> --------->:新建分支

git checkout -b <分支名称> --------->:新建并切换分支

git checkout <分支名称> --------->:切换分支
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

014、分支提交

git push origin <分支名称>
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

015、获取秘钥,并查看秘钥

ssh-keygen -t rsa -C <邮件名称> ------->获取秘钥


cat ~/.ssh/id_rsa.pub ------->查看秘钥

016、更新本地仓库

git fetch --all --------->:更新git remote 中所有的远程仓库所包含分支的最新commit-id 

git pull --------->:将本地库更新至远程库的最新状态

017、合并文件

git merge <分支名称>

 如要转载,请注明出处,出处是  Alley-巷子,打个广告,请关注Alley-巷子。

001、初始化仓库,创建git仓库

git init

002、配置个人信息

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令
git config --global user.name <名字> --------->:配置用户名

git config --global user.email <邮箱>--------->:配置邮箱

git config --list --------->:查看配置信息

git config --global user.name  --------->:查看用户名

git config --global user.email --------> :查看邮箱
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

003、将工作区文件添加到缓存区

git add <文件名称>

004、查看文件状态

git status
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

005、将缓存区的文件添加到版本库

git commit -m "提交注释的说明"  --------->将缓存区的文件添加到版本库中 并加上注释
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

006、查看提交的版本日志

git log
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

007、查看文件最新改动的地方

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令
git diff <文件名称> --------->:查看工作区与暂存区文件的比较

git diff --cached ------------>:查看暂存区与版本库文件的比较

git diff master ------------>:查看工作区与版本区文件的比较

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

-开头的行,是只出现在源文件中的行

+开头的行,是只出现在目标文件中的行

空格开头的行,是源文件和目标文件中都出现的行

差异按照差异小结进行组织,每个差异小结的第一行都是定位语句,由@@开头,@@结尾

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

008、版本回退

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令
git reset --hard HEAD^ --------->回退到上一个版本

git reset --hard HEAD^^ --------->回退到上上个版本

git reset --hard HEAD~N --------->回退到第N个版本 N是一个整数

git reset --hard 版本号 --------->回退到指定版本
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

009、查看所有版本号

git reflog
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

 010、删除操作

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令
git rm <文件名称> --------->删除暂存区分支上的文件, 同时工作区也不需要这个文件

git rm -f <文件名称> --------->强制删除文件

git rm --cached <文件名称> --------->删除暂存区分支上的文件, 但本地又需要使用, 只是不希望这个文件被版本控制
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

011、git推送

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令
git push -u origin master --------->将文件上传到github上

git remote --------->查看远程仓库名称 默认 origin

git remote -v --------->查看当前的远程仓库名称和对应的地址

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

012、克隆

git clone <仓库地址>

013、创建分支

【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令
git branch --------->:查看本地分支列表

git branch <分支名称> --------->:新建分支

git checkout -b <分支名称> --------->:新建并切换分支

git checkout <分支名称> --------->:切换分支
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

014、分支提交

git push origin <分支名称>
【git】------git的基本命令 (此文章转载我的老师 Alley-巷子)
【git】------git的基本命令

015、获取秘钥,并查看秘钥

ssh-keygen -t rsa -C <邮件名称> ------->获取秘钥


cat ~/.ssh/id_rsa.pub ------->查看秘钥

016、更新本地仓库

git fetch --all --------->:更新git remote 中所有的远程仓库所包含分支的最新commit-id 

git pull --------->:将本地库更新至远程库的最新状态

017、合并文件

git merge <分支名称>

 如要转载,请注明出处,出处是  Alley-巷子,打个广告,请关注Alley-巷子。