官方文档地址
本地代码上传到远程仓库的master
git init //初始化本地代码,新建.git 文件
git status // 查看本地文件与服务的差别
git add . //讲所有文件添加到本地仓库中
git commit -m "添加本次提交记录" // 为本次记录添加说明
git remote add origin https://domain.com // 讲本地代码与远程仓库做关联(远程仓库存在的情况下)
git pull --rebase origin master // 讲代码定位到origin master 主仓库下
git push -u origin master // 推送代码到master分支
本地创建分支并上传到远程服务器
git branch // 查看本地分支
git branch -a // display all the branch including remote branch
git checkout -b dev // switch branch to dev
git push origin <local branch name>:<remote branch name> // link local branch to remote branch and push to the serve
git push origin:<remote branch name> // delete remote branch
删除本地分支
git branch -d 分支名
拉取远程分支到本地
git pull origin/dev // get dev branch to local branch
pull a different branch and switch to the branch
git checkout -b dev origin/dev
合并本地分支到master分支
git checkout master // switch to master branch
git pull origin master // get the newest code in the master branch
get merge dev // merge dev code to the local branch
git push origin -d dev // delete dev branch
放弃文件更改
// 1. if you did not use git add command to cache the code
git checkout --filename // discard the filename modify
git checkout . // discard all the modified content in this repository
// 2. if you use git add command to cache the code
git reset HEAD filename // discard the filename
git reset HEAD // discard all the modified file
// 3. if you already use git commit command to cache the code
git reset --hard HEAD^ // go back to the last commit status
git reset --hard commit id // go back to any commit status, commitId is a serial string made by git itself
tags
git push origin --tags // 将tags发送到服务器
git tag // inspect all the tag
git show v0.0.1 // show the descripiton info
git tag -d v0.0.1 // delete v0.0.1 tag
git tag -a v0.0.1 -m 'descript this tag'
progit.pdf
progit_v2.1.34.pdf