设置用户签名
git config --global user.name 用户名
git config --global user.email 邮箱
本地库与远程库的操作
初始化本地库
git init
创建远程仓库别名
git remote -v 查看当前所有远程地址别名
git remote add 别名远程地址
git remote -v //查看当前所有远程地址别名
git remote add 别名 远程地址
git remote add ori https://gitee.com/tianzhen/wenjian
推送本地分支到远程仓库
git push 别名 分支
git push 别名 分支
git push ori master
克隆远程仓库到本地
git clone 远程地址
git clone 远程地址
git clone https://gitee.com/tianzhen/wenjian
拉取远程库内容
git pull 远程库地址别名 远程分支名
git pull ori master
查看本地库状态
git status
添加暂存区
git add 文件名
git add . //提交全部文件
提交本地库
git commit -m "日志信息" 文件名
git commit -m "第一次提交" .
git commit -m "diyicitijiao"
历史版本
查看历史版本
git reflog 查看版本信息
git log 查看版本详细信息
git reflog
git log
版本穿梭
git reset --hard 版本号
git reflog 查看当前历史记录版本
git reflog
git reset --hard 版本号
分支操作
查看分支
git branch -v
git branch -v
创建分支
git branch 分支名
git branch 分支名
git branch master
切换分支
git checkout 分支名
git checkout 分支名
git checkout ori
合并分支
git merge 分支名
git merge 分支名
git merge ori
git merge master
命令总和
常用命令
命令名称 | 作用 |
---|---|
git config --global user.name 用户名 | 设置用户签名 |
git config --global user.email 邮箱 | 设置用户邮箱 |
git init | 初始化本地库 |
git status | 查看本地库状态 |
git add 文件名 | 添加到暂存区 |
git commit -m “日志信息” 文件名 | 提交到本地库 |
git reflog | 查看历史记录 |
git reset --hard 版本号 | 版本穿梭 |
分支的操作命令
命令名称 | 作用 |
---|---|
git branch 分支名 | 创建分支 |
git branch -v | 查看分支 |
git checkout 分支名 | 切换分支 |
git merge 分支名 | 把指定的分支合并到当前分支上 |
远程仓库的操作命令
命令名称* | 作用 |
---|---|
git remote -v | 查看当前所有远程地址别名 |
git remote add 别名 远程地址 | 起别名 |
git push 别名 分支 | 推送本地分支上的内容到远程仓库 |
git clone 远程地址 | 将远程仓库的内容克隆到本地 |
git pull 远程库地址别名 远程分支名 | 将远程仓库对于分支最新内容拉下来后与当前本地分支直接合并 |