git初次使用

git的初次使用

  • 安装-sudo apt install git
  • 初始化-git init
  • 提交
    • git add filename
    • git commit -m "版本说明"
  • 查看版本状态-git status
  • 查看-git log --pretty=oneline
  • 查看曾经的记录-git reflog
  • 版本修改
    • git reset --hard HEAD^/HEAD~num 返回上一个/前n个版本
    • git reset --hard 版本序列号前4位 返回指定版本
  • 撤销修改
    • git checkout filename 丢弃工作区修改
    • git resest HEAD filename 丢弃暂存区修改
  • 对比文件
    • git diff HEAD filename 对比工作区有什么不同
    • git diff HEAD HEAD^ 对比上一个版本有什么不同
  • 删除文件
    • git rm filename
    • git commit
  • 分支
    • git branch 查看分支
    • git branch branchname 创建分支
    • git checkout branchname 切换分支
    • git checkout -b branchname 创建并切换分支
    • git merge branchname 合并分支
      • git merge --no-ff -m "说明" branchname 禁用快速合并
    • git branch -d branchname 删除分支
  • 封存工作区
    • git stash 封存
    • git stash list 查看
    • git stash pop 解除封存
  • 案例
当前正在branch1工作  
git stash
git checkout -b branch2
修改并提交
git checkout master
git merge --no-ff -m "合并分支" branch2
git checkout dev
git stash pop

gitHub的初次使用

  • github上新建一个仓库
  • vi ~/.gitconfig
    email = 邮箱地址
    name = 用户名
  • ssh-keygen -t rsa -C "邮箱地址"
  • 把ssh公钥添加到github中
  • git clone 克隆地址
  • git push orgin branshname -上传分支
  • 跟踪远程分支
    • git branch --set-upstream-to=origin/远程分支名 本地分支名
  • git pull orgin 远程分支名 -远程拉去代码
上一篇:php – 结帐字段:隐藏和显示现有字段


下一篇:php – woocommerce在结帐和购物车页面更改价格