zoukankan      html  css  js  c++  java
  • github基本命令

    https://github.com/explore 使用github网站搜索资源

    具体搜索 Git教程 - 廖雪峰的官方网站

    一. git配置命令

    1.设置用户名

    git config --global user.name "your name" 

    2.设置邮箱

    git config --global user.email "your_email@youremail.com" 

    3.添加远程地址

    git remote add origin git@github.com:yourName/yourRepo.git 

    4.从远程克隆

    git clone git@github.com:yaoshuangjiang/ysj.git 

    5.查看远程库的信息

    git remote     git remote -v显示更详细的信息

    二. git基本命令

    1.初始化仓库

    git init 将当前目录初始化为git仓库

    2.添加文件

    git add <file>   添加文件  -A(所有文件)  git add -u 添加修改和删除的文件

    3. 删除文件

    git rm <file>  删除文件

    4.提交到仓库

    git commit -m <"tips"> 把文件提交到仓库

    5.查看仓库状态

    git status 查看仓库状态

    6.比较代码

    git diff <file> 查看 git diff    #是工作区(work dict)和暂存区(stage)的比较 git diff --cached    #是暂存区(stage)和分支(master)的比较

    7.查看日志

    git log <file> 查看修改日志

    8.版本回退

    (1)git reset --hard HEAD^ 回退到上一版本,上上一个版本就是HEAD^^,当然往上100个版本写100个^比较容易数不过来,所以写成HEAD~100

    (2)git reset --hard <commitid> 回退到某个提交  commitid可以用git reflog

    10.查看命令

    git reflog 用来记录你的每一次命令

    11.把文件在工作区的修改全部撤销

    git checkout -- <file> 把文件在工作区的修改全部撤销

    12.提交到远端

    git push origin master

    13.从远端拉取

    git pull

    三.分支:

    1.查看分支

    git branch 

    2. 创建分支

    git branch <name>

    3.切换分支

    git checkout <name> 

    4.创建+切换分支

    git checkout -b <name> 

    5.合并某分支到当前分支

    git merge <name> 

    6.删除分支

    git branch -d <name> 

  • 相关阅读:
    Python 容器用法整理
    C/C++中浮点数格式学习——以IEEE75432位单精度为例
    关于C/C++中的位运算技巧
    [GeekBand] C++11~14
    [GeekBand] 探讨C++新标准之新语法——C++ 11~14
    [GeekBand] 面向对象的设计模式(C++)(2)
    [GeekBand] 面向对象的设计模式(C++)(1)
    [GeekBand] STL与泛型编程(3)
    [GeekBand] STL与泛型编程(2)
    [GeekBand] STL与泛型编程(1)
  • 原文地址:https://www.cnblogs.com/yaosj/p/6564203.html
Copyright © 2011-2022 走看看