zoukankan      html  css  js  c++  java
  • git 使用

    一、创建新分支

    1. git branch 查看已有的所有分支。

    2. git branch andy 创建名叫andy的分支。

    3. git branch  再看看是不是多了一个叫andy的分支,例如:

      *master

        andy

    4. git checkout andy 切换到andy分支

    5. git push --set-upstream origin andy  将andy分支推送到远程仓库

    6. git checkout master 切换回mster主分支。

    二、删除分支

    1. git push origin --delete andy  把远程的andy分支删除掉

    2. git branch -d andy  同时把本地对应的andy分支删掉 

    三、clone 分支

    git clone 下来的仓库是没有其分支的,怎么办?如下:

    1. git branch -a,列出所有分支名称如下:
      remotes/origin/andy
      remotes/origin/master
    2. git checkout -b andy origin/andy,作用是checkout远程的andy分支,在本地起名为andy分支,并切换到本地的andy分支

    3. git branch 看看就有了。

     四、回退指定版本

    A. 回滚指定文件

    1. git reset e5ca2e9a74634b744b19ed05252ccb49092bff8e ./Elasticsearch.php

    2. git commit -m"reset"

    3. git checkout ./Elasticsearch.php

    4. git push

    完成

    B. 回滚整个项目

    1. git reset --hard e5ca2e9a74634b744b19ed05252ccb49092bff8e

    五、Git 多平台换行符问题(LF or CRLF)

    如果涉及到在多个系统平台上工作,推荐将 git 做如下配置:

    git config --global core.autocrlf input
    git config --global core.safecrlf true

    http://kuanghy.github.io/2017/03/19/git-lf-or-crlf

  • 相关阅读:
    nvidia tx1使用记录--基本环境搭建
    STL hashtable阅读记录
    Linux strace命令
    转一篇:Reactor模式
    C++ 模板特化以及Typelist的相关理解
    C++ 内联函数inline
    迭代器失效的几种情况总结
    C++ Class与Struct的区别
    C++中string.find()函数,string.find_first_of函数与string::npos
    C/C++ 中长度为0的数组
  • 原文地址:https://www.cnblogs.com/bootoo/p/5131734.html
Copyright © 2011-2022 走看看