git

一、git和github的关系
  • git:版本控制工具。
  • github:提供git仓库托管服务的平台。
  • 用git控制版本,用github托管git仓库到网络。
 
二、git
  • 初始化配置github的用户名和邮箱
    • git config --global user.name "your name"
    • git config --global user.email "email@email.com"
  • 创建本地仓库
    • git init:把当前目录设置为git仓库
  • 添加远程仓库(把当前仓库与远程仓库关联)
    • git remote add origin 仓库地址
    • origin则为远程仓库在本地的名字
  • 获取远程仓库分支信息
    • git fetch
  • 查看本地和远程分支
    • git branch -a
  • 本地分支操作
    • 创建:git checkout -b name
    • 重命名:git branch -m name newname
    • 删除:git branch -d name
    • 绑定远程分支:git branch --set-upstream-to=origin/远程分支名 本地分支名
  • 拉取代码
    • git pull
    • git stash:将本地修改暂存,用于pull有冲突时。
  • 推送代码
    • git add 文件名(.表示当前目录下所有文件):把仓库下的文件添加到版本库
    • git commit -m  “注释”  :提交所有的修改
    • git push  :将本地仓库修改推送到远程仓库
  • 克隆远程仓库到本地
    • git clone 地址
  • 回退
    • git reset HEAD^ :所有文件回退到上一次commmit
    • git reset HEAD^ filename:该文件回退到上一次commit
    • git reset commmitName:回退到指定commit
  • 其它
    • 查看仓库状态
      • git status:查看仓库内文件的修改、添加、提交状态
    • 查看文件修改情况
      • git diff 文件名
    • 查看历史纪录
      • git log
    • 配置代理
      • git config --global http.proxy http://127.0.0.1:8080
        git config --global https.proxy https://127.0.0.1:8080

 
三、github
  • star:给项目点赞。
  • watch:关注项目动态。
  • follow:关注作者动态。
  • fork:在自己的github仓库中建立原项目的一个分支,修改后可以pull request到原项目,经作者同意后可以整合到原项目中。
posted @ 2019-05-12 13:18  woldcn  阅读(125)  评论(0)    收藏  举报