git init | 初始化一个本地git库 |
git add . | 将工作区的代码文件全部提交到缓存区(注意后面的 . ) |
git add good.txt | 将工作区的代码文件 ‘good.txt’提交到缓存区 |
git rm --cached good.txt | 将缓存区代码文件‘good.txt’移除工作区 |
git commit -m "提交说明" | 将工作区的代码提交到本地库(git commit -m "提交说明"-》必须先用git add .命令) |
git commit -a -m '提交说明' | 修改文件,直接提交,若未新增的 |
git push [别名] [分支名] | 将本地分支推送到远程分支上(git push origin master) |
git clone [远程地址] | 克隆( git clone https://gitee.com/chg/huashan.git) |
git pull [别名] [分支名] | 将远程分支拉取到本地分支上(git pull origin master) |
git push --mirror https://git.eyuno.com/sang/yin.git | git历史整体迁移命令 |
git push origin [远程分支名] --force | 回退版本后,将本地分支强制推送到远程分支 |
git branch -v | 查看有多少分支 |
git branch | 查看当前自己所在的分支 |
git branch -a | 查看服务器的所有分支以及自己当前所在的分支 |
git branch branchName | 在本地创建一个命名为branchName的分支 |
git branch -d branchName | 删除本地的分支branchName |
git checkout master | 切换到分支"master"上 |
git merge hot_fix | 将分支"hot_fix"合并到当前所在分支上 |
git remote -v | 查看当前所有远程地址别名 |
git remote add [别名] [远程地址] | 创建远程库地址别名(git remote add origin https://gitee.com/cgsg/huashan.git) |
git reset --hard 471af7c | git版本回退/前进 ,"471af7c" 表示回退的版本号,通常与git reflog搭配 |
git reset --hard HEAD^ | git版本回退到上一个版本 |
git reset --hard HEAD^^ | git版本回退到上两个版本(^几个就回退几个版本) |
git reset --hard HEAD~3 | git版本回退上几个版本 3 表示回退3个版本 |
rm aaa.txt | git删除某个文件 |
git diff apple.txt | git将工作区的文件和暂存区版本文件比较 |
git diff HEAD apple.txt | git将工作区的文件和本地库版本文件比较 |
git diff HEAD^ apple.txt | git将工作区的文件和本地库某个历史版本文件比较 |
git diff | 不带文件名比较的是多个文件 |
git log | 查看历史记录 |
git log --pretty=oneline | 查看历史记录(每个版本只显示一行,显示的更友好) |
git log --oneline | 查看历史记录(每个版本只显示一行,且只显示一部分版本号) |
git reflog | 查看历史记录(比git log --oneline信息更多) |
git tag -a v1.4.1 -m "my version 1.4" | 在当前分支打一个版本迭代的标签 -a 构建tag标签名字,-m 确定标签具体信息 |
git push origin --tags | 把tag推送至远程 |