• 版本控制工具 git的基本使用


    git基本操作:

    git clone https://代码地址 =>> 克隆代码到本地

    git branch =>> 查看当前的分支

    git branch【branch name】 =>> 创建新的分支

    git checkout【branch name】 =>> 切换到指定分支

    git status =>> 查看本地代码修改状态

    git add file name / git add . =>> 把要提交的所有修改放到本地仓库暂存区

    git commit -m "your action description" =>> 一次性把暂存区的所有修改提交到本地仓库

    git push origin【 local branch name】 : 【remote branch name】   =>>提交文件到远程仓库

    git rm file name -r -f =>> 从本地仓库删除文件

    git branch -d 【branch name】 ==>> 删除本地分支

    git push origin --delete 【branch name】==>> 删除远程分支

    git pull origin 【local branch name】 : 【remote branch name】 =>> 从远程分支拉取代码到本地

    日志查看:q ==>> 退出日志查看

    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 push origin --force =>> 回退后的代码提交到远程仓库

    撤销修改:

    git checkout -- file =>> 当你改乱了工作区某个文件的内容,想直接丢弃工作区的修改时

    git reset HRAD [file] =>> 当你不但改乱了工作区某个文件的内容,还添加到了暂存区时,想丢弃修改,分两步,第一步用命令git reset HEAD <file>,第二步git checkout -- file。

    记录一次分支merge的过程:

    首先将分支中的修改提交到本地仓库: git commit -m "your action description",并提交到远程仓库:git push origin "your action description":"remote branch name'

    使用git status 命令确认本地仓库是否清空,

    切换到主分支: git checkout master

    再将主的修改提交到本地仓库: git commit -m "your action description",并提交到远程仓库:git push origin "your action description":"remote branch name'

    本地分支拉取远程主分支代码:git pull origin 【local branch name】 : 【remote master branch】 =>> 从远程分支拉取代码到本地

    分支切换到主分支,最后执行merge操: git merge your local branch name   

    如果有冲突,解决冲突,提交本地主分支代码:提交到本地仓库: git commit -m "your action description",并提交到远程仓库:git push origin "your action description":"remote branch name'

  • 相关阅读:
    iOS优秀博文合集
    iOS优化策略
    iOS编码规范
    二维码
    Objective-C Http常用API 同步请求与异步请求
    iOS开发之Runtime函数
    ios开发之常用宏的定义
    iOS开发之动画编程的几种方法
    iOS开发之常用第三方框架(下载地址,使用方法,总结)
    使用OC和swift创建系统自带的刷新界面
  • 原文地址:https://www.cnblogs.com/dadouF4/p/10063635.html
Copyright © 2020-2023  润新知