- git clone https://代码地址 =>> 克隆代码到本地
- git branch =>> 查看当前的分支
- git branch new branch name =>> 创建新的分支
- git checkout branch name =>> 切换到指定分支
- git status =>> 查看本地代码修改状态
- git add file name / git add . =>> 把要提交的所有修改放到本地仓库暂存区
- git commit -m "your action description" =>> 一次性把暂存区的所有修改提交到本地仓库
- git push origin your local branch name : remote branch name =>>提交文件到远程仓库
- git rm file name -r -f =>> 从本地仓库删除文件
- git pull origin your local branch name : remote branch name =>> 从远程分支拉取代码到本地
- git checkout -b your local branch name origin/remote branch name =>> 在本地创建分支dev并切换到该分支
不成功需要 使用 git fetch 命令用于从另一个存储库下载对象和引用。 - 日志查看:
git log [--pretty=oneline] =>>查看git提交历史记录,加上参数--pretty=oneline可以精简日志信息
git relog =>>如果在回退以后又想再次回到之前的版本,git reflog 可以查看所有分支的所有操作记录(包括commit和reset的操作),包括已经被删除的commit记录,git log则不能察看已经删除了的commit记录 - 版本回退:
版本git reset --hard HEAD^ =>>回到上一个版本
git reset --hard HEAD^^ =>> 回到前两个版本
git reset --hard HEAD~100 =>>回到前100个版本
git reset --hard commit_id =>> 回到指定版本id的版本 - 撤销修改:
git checkout -- file =>> 当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时
git reset HRAD [file] =>> 当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令git reset HEAD <file>,第二步git checkout -- file。 - 记录一次分支merge的过程
- 首先将分支中的修改提交到本地仓库,git commit -m "your action description"
- 切换到主分支,git checkout master
- merge操作,git merge your local branch name
转载于:https://www.cnblogs.com/dadouF4/p/10063635.html