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

    Git

    团队协作开发

    git init 初始化

    git add file.py 把代码放入Git暂存区
    git add . 把当前整个目录提交

    git commit -m "xxx" 把代码从Git暂存区放到Git仓库

    git config --global user.email "you@example.com"
    git config --global user.name "Your Name"

    ******************撤回代码*******************
    git checkout file.py 把代码从暂存区回滚到工作区,前提是没有commit
    cat file.py 显示更新后
    cat file.py 显示更新前

    git status 查看当前代码修改状态

    git log 查看提交日志
    git log --pretty=oneline 只显示第一行的ID

    git reset --hard HEAD^ 把版本号回滚到上一版本

    git reset --hard 123jnd 回滚到指定版本号

    git reflog 查看所有操作记录,找到对应的版本号

    ******************删除文件******************
    rm file 本地删除
    git add/rm file 提交到暂存区
    git reset HEAD fike 从暂存区回滚到工作区
    git checkout -- fike 把工作区里的操作撤销


    ******************GitHub远程下载代码******************
    git clone https://github.com/YANGYANGMING/CMDB.git 用http可以直接下载到本地
    用ssh需要用户名认证


    远程创建空仓库

    把本地仓库推到远程(已经有仓库)
    git remote add origin https://github.com/YANGYANGMING/CMDB.git
    git push -u origin master

    分支:
    git checkout -b branch_name 创建分支
    git checkout branch_name 切换分支

    git pull 从远程更新代码到本地
    git push 把本地代码推到远程
    git merge branch_name 合并分支


    master

    dev

    yyy-dev
    mmm-dev

    bug-101

    git stash 把当前工作环境临时保存
    git stash apply 回复之前保存的临时工作
    git stash list 查看临时保存的列表
    git stash drop 删除当前临时保存的环境备份
    git stash pop 回复并删除临时保存的备份

    参考https://www.cnblogs.com/alex3714/articles/5930846.html

  • 相关阅读:
    【转】卡特兰数四个公式(简单)
    【基础算法-ST表】入门 -C++
    【题解】[Nwerc 2006]escape -C++
    C#高级编程第11版
    C#高级编程第11版
    C#高级编程第11版
    C#高级编程第11版
    C#高级编程第11版
    109th LeetCode Weekly Contest Knight Dialer
    109th LeetCode Weekly Contest Number of Recent Calls
  • 原文地址:https://www.cnblogs.com/yangyangming/p/11294534.html
Copyright © 2011-2022 走看看