zoukankan      html  css  js  c++  java
  • Git基本操作

     1 git使用
     2 一,下载
     3         https://git-for-windows.github.io
     4 二,安装
     5         运行 Git Bash
     6 Linux 环境下:
     7         ubuntu debian ---sudo apt-get install git
     8         centos redhat  ----yum install git
     9 三,用户配置
    10         $ git config --global user.name #uname
    11         $ git config --global user.eamil #eamil
    12 四,本地代码仓库
    13         D:/test/   touch demo.txt   #本地磁盘
    14         $ git init     #初始化操作    
    15         $ git add . #add . 添加所有文件到暂存区
    16         $ git commit -m "注解部分"
    17         $ git status   #查看其状态
    18 五,远程仓库
    19         http://www.github.com
    20         http://git.oschina.net
    21         在github登陆--创建仓库--复制仓库地址《http地址&ssh地址 任意一个》
    22         2》,本地代码库添加远程代码库
    23         $ git remote add origin https://github.com/sharecorner/demo.git #remote 参数 add origin 为远程仓库地址添加别名为:origin
    24         $ git push origin master #把本地代码推到远程仓库
    25 六,团队协作
    26         $ git clone https://github.com/sharecorner/demo.git #把远程仓库代码复制到本地
    27         修改之后,另一个coder 需要仓库代码需要:$ git pull origin master
    28 七,分布式版本控制
    29 八,git操作
    30         $ git add <file1,file2> # 添加文件
    31         $ git add . # 添加当前目录所有变化的额文件
    32         $ git rm <file> # 删除文件
    33         $ git mv <srcfile> <newfile> # 移动或改名
    34     日志操作
    35         $ git log #查看项目的日志
    36         $ git log # 查看某个文件的日志
    37         $ git log . # 查看本目录的日志
    38         $ git log --pretty=oneline 让日志单行显示
    39 九,版本切换
    40         $ git reflog # 查看版本变化
    41         $ git reset --hard HEAD^ # 第一版本 # ^^ 第二版本 ^^^ # 第三版本
    42         $ git reset --hard 版本号
    43 十,分支管理
    44         $ git branch  # 查看分支 master 主分支
    45         $ git branch test # 创建分支test
    46         $ git checkout test # 切换分支test
    47         $ git checkout -b test # 快速创建分支 立即切换test分支
    48         $ git merge de # 合并分支 在主分支下合并 分 分支
    49         $ git branch -d test # 删除分支
    50 十一,远程仓库
    51         $ git remote -v # 查看远程仓库
    52         $ git remote remove <远程仓库别名>
    53         $ git remote add origin https://github.com/sharecorner/demo.git #添加远程仓库 并未取别名 origin
    54         $ git rename <oldName> <newName> # 重新命名远程仓库名称
    55 十二,公钥登陆
    56         $ git remote add demoaddr git@github.com:sharecorner/demo.git     #创建远程仓库ssh地址
    57         ssh-keygen -t rsa -C "eamonxj@gmail.com" # 生成密钥 id_rsa&id_rsa.pub 复制公钥id_rsa.pub内容到github 个人管理--ssh公钥--添加公钥--保存
    58         以后push本地到远程仓库就可以免登陆
    59         
  • 相关阅读:
    使用Struts时,JSP中如何取得各个会话中的参数值?
    JUnit —— TestSuite 的使用
    如何修改 Ubuntu 的字符集?
    如何修改 VIM 制表符的空格数?
    最遥远的距离
    二分法求平方根(Python实现)
    Hadoop 学习之路之MapReduce原理
    JDK 1.8源码阅读 TreeMap
    JDK 1.8源码阅读 HashMap
    JDK 1.8源码阅读 HashSet
  • 原文地址:https://www.cnblogs.com/sharecorner/p/6618006.html
Copyright © 2011-2022 走看看