Basic Commands of git git] ------
001, initialization warehouse, created git repository
git init
002, configure your personal information
git config --global user.name <name> --------->: Configure a username git config --global user.email <mailbox> --------->: configure mailbox git config --list --------->: Check the configuration of git config --global user.name --------->: View the user name git config --global user.email - ------>: View mailbox
003, add files to the workspace cache
git add <file name>
004 Viewing File Status
git status
005, add files to the repository cache
git commit -m "the statement submitted by the comment" ---------> add files to the cache repository and add comments
006, Revision Log View Submitted
git log
007, view the latest changes to the local file
git diff <file name> --------->: View the work area and the staging area file comparison git diff --cached ------------>: View the staging area the repository file comparison git diff master ------------>: View the work area and the zone file version comparison
- beginning of the line, is only present in the source file line
+ Beginning of the line, is only present in the target file line
Line that begins with a space, a line of source and destination files are appearing
差异按照差异小结进行组织,每个差异小结的第一行都是定位语句,由@@开头,@@结尾
008、版本回退
git reset --hard HEAD^ --------->回退到上一个版本 git reset --hard HEAD^^ --------->回退到上上个版本 git reset --hard HEAD~N --------->回退到第N个版本 N是一个整数 git reset --hard 版本号 --------->回退到指定版本
009、查看所有版本号
git reflog
010、删除操作
git rm <文件名称> --------->删除暂存区
或分支
上的文件, 同时工作区也不需要这个文件 git rm -f <文件名称> --------->强制删除文件 git rm --cached <文件名称> --------->删除暂存区
或分支
上的文件, 但本地又需要使用, 只是不希望这个文件被版本控制
011、git推送
git push -u origin master --------->将文件上传到github上 git remote --------->查看远程仓库名称 默认 origin git remote -v --------->查看当前的远程仓库名称和对应的地址
012、克隆
git clone <仓库地址>
013、创建分支
git branch --------->:查看本地分支列表 git branch <分支名称> --------->:新建分支 git checkout -b <分支名称> --------->:新建并切换分支 git checkout <分支名称> --------->:切换分支
014、分支提交
git push origin <分支名称>
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 config --global user.name <名字> --------->:配置用户名 git config --global user.email <邮箱>--------->:配置邮箱 git config --list --------->:查看配置信息 git config --global user.name --------->:查看用户名 git config --global user.email --------> :查看邮箱
003、将工作区文件添加到缓存区
git add <文件名称>
004、查看文件状态
git status
005、将缓存区的文件添加到版本库
git commit -m "提交注释的说明" --------->将缓存区的文件添加到版本库中 并加上注释
006、查看提交的版本日志
git log
007、查看文件最新改动的地方
git diff <文件名称> --------->:查看工作区与暂存区文件的比较 git diff --cached ------------>:查看暂存区与版本库文件的比较 git diff master ------------>:查看工作区与版本区文件的比较
-开头的行,是只出现在源文件中的行
+开头的行,是只出现在目标文件中的行
空格开头的行,是源文件和目标文件中都出现的行
差异按照差异小结进行组织,每个差异小结的第一行都是定位语句,由@@开头,@@结尾
008、版本回退
git reset --hard HEAD^ --------->回退到上一个版本 git reset --hard HEAD^^ --------->回退到上上个版本 git reset --hard HEAD~N --------->回退到第N个版本 N是一个整数 git reset --hard 版本号 --------->回退到指定版本
009、查看所有版本号
git reflog
010、删除操作
git rm <文件名称> --------->删除暂存区
或分支
上的文件, 同时工作区也不需要这个文件 git rm -f <文件名称> --------->强制删除文件 git rm --cached <文件名称> --------->删除暂存区
或分支
上的文件, 但本地又需要使用, 只是不希望这个文件被版本控制
011、git推送
git push -u origin master --------->将文件上传到github上 git remote --------->查看远程仓库名称 默认 origin git remote -v --------->查看当前的远程仓库名称和对应的地址
012、克隆
git clone <仓库地址>
013、创建分支
git branch --------->: View a list of the local branch git branch <branch name> --------->: New branch git checkout -b <branch name> ------ --->: New and handover branch git checkout <branch name> --------->: branch switching
014, submit branch
git push origin <branch name>
015, access keys, and view keys
ssh-keygen -t rsa -C <message name> -------> Get keys cat ~ / .ssh / id_rsa.pub -------> See keys
016, updates the local warehouse
git fetch --all --------->: update the latest commit-id git remote in the remote repository contains all branches
git pull --------->: updates to the local library the latest status of the remote library
017, merge files
git merge <branch name>
To reprint, please indicate the source, the source is Alley- alley, play ad, please pay attention to Alley- alley.