git常用命令
git init # 初始化本地git环境
git clone # 克隆一份代码到本地仓库
git pull # 把远程库的代码更新到工作台
git pull -- rebase origin master # 强制吧远程库的代码更新到当前分支上
git fetch # 把远程库的代码更新到本地库
git add
git commit
git push # 把本地库的修改提交到远程库中
git branch # 查看远程分支
git checkout # 切换分支
git checkout b # 新建分支
git checkout d # 删除分支
git merge master # 将当前分支合并到master分支上
git stash # 把未完成的修改缓存到栈容器中
git stash list # 查看所有缓存
git blame (Filename) # 查看某个文件的每一行的修改记录
git log # 查看当前分支上面的日志信息
git diff # 查看当前没有add的内容
git diff --cache # 查看已经add但是没有commit的内容
git diff HEAD # 上面两个内容的合并
git reset -- hard HEAD # 撤销本地修改
克隆一个全新项目,完成新功能并提交
git clone xxxx # 克隆代码库
git checkout -b dev_test # 新建分支
修改代码
git add # 把修改加入stage中
git commit -m "注释" # 提交修改到test分支中
review代码
git checkout master # 切换到master分支
git pull # 更新代码
git checkout test # 切换到test分支
git mege master # 把主分支的内容合并到test分支中
git push origin test # 把test分支的代码push到代码库
在分支上开发,突然需要修改bug
// 当前处于test 分支
git stash // 将修改的内容保存
git checkout bugFixBranch // 切换到需要修bug的分支
git pull --rebase origin master // 将代码更新到最新
fix the bug // 修复bug
git add .
git commit -m "" // 提交修改
git push
git checkout test // 切换回test 分支
git stash pop // 将修改的内容导出来
继续
Comments