• Git常用命令


    git init    | 初始化本地项目,创建一个本地git仓库

    git fetch origin home   | 把远程分支home的代码更新到本地 

    git clone XXX   | 克隆一份代码到本地仓库 XXX代表远程仓库的url地址

    git pull –rebase origin master   | 强制把远程库的代码更新到当前分支上

    git add .   | 把修改添加到本地缓存中

    git commit -m "修改说明"   | 添加修改说明

    git push origin test   | 把本地库的修改提交到远程库的test分支

    git branch -r / -a   | 查看远程分支 / 全部分支

    git checkout master/branch   | 切换到某个分支

    git checkout -b test   | 新建test分支

    git checkout -d test   | 删除test分支

    git merge master  | 把master分支上的修改同步到当前所在分支

    git merge tool   | 调用合并工具

    git stash   | 把未完成的修改缓存到栈容器中

    git stash list   |查看所有缓存

    git stash pop   | 恢复本地分支到缓存状态

    git blame someFile   | 查看某个文件的每一行的修改记录【谁在什么时候修改的】

    git status  | 查看当前分支有哪些修改

    git log   | 查看当前分支上的日志信息

    git diff   | 查看当前没有add的内容

    git diff --cache   | 查看已经添加到本地缓存中但是没有保存到本地仓库的内容

    git diff HEAD   | 上面两个内容的合并

    git reset --hard HEAD   | 撤销本地修改

    echo $HOME   | 查看git comfig 的HOME 路径

    export $HOME=/c/gitconfig   | 配置git config 的HOME路径

    回退到上一个版本

    git reset --hard HEAD^      回退到上个版本

    git reset --hard HEAD~3     回退到前3次提交之前,以此类推,回退到n次提交之前

    git reset --hard dfhavbin  回退到指定版本 dfhavbin 为版本号

    然后强制推送到远程库

    git push origin HEAD -f

    多人协作修改git操作流程

    1.  git clone XXX   | 克隆代码库

    2.  git checkout -b test   | 新建分支

    3.  modify some files   | 完成修改

    4.  git add .   | 把修改添加到缓存中

    5.  git commit -m "修改说明"   | 添加修改说明

    6.  review  | 代码

    7.  git checkout master   | 切换到master分支

    8.  git pull   | 更新代码

    9.  git checkout test   | 切换到test分支

    10. git merge master   | 把master分支的代码合并到test分支

    11. git push origin test   | test是分支名 把test分支的代码push到远程库

    12. git branch -vv  | 查看自己当前在哪个分支上

    13. git remote -v |查看远程地址

    14. git remote set-url origin 仓库地址 |修改远程仓库地址

    15. git commit --amend -m 修改文本 |修改commit

  • 相关阅读:
    着迷英语900句总结
    SQL Server 常见数据类型
    SQL Server视频总结
    第三次SLA文档学习
    Rosetton Stone Summary
    【周总结】2018-10-19—2018-11-25
    学生信息管理系统总结
    VB中 EOF 和 BOF 的区别
    VB中 On error 的用法
    VB中 . 与 ! 的区别
  • 原文地址:https://www.cnblogs.com/chefweb/p/8358858.html
Copyright © 2020-2023  润新知