zoukankan      html  css  js  c++  java
  • git 常用命令

    目录

    • 一般命令

    • 配置

    • 提交、缓存

    • 推送拉取

    • 分支

    一、一般命令

    #查看git命令帮助
    git help
    #查看某个命令的帮助
    git cmd --help
    #初始化一个仓库
    git init
    #查看git状态;<pathspec>是指文件集合,可以不加默认是当前目录
    git status <pathspec>
    #克隆代码  git
    git clone 仓库Url  <dirname>
    #克隆指定版本
    git clone -b branchname 仓库Url  <dirname>
    #查看当前文件状态
    git status

    二、配置

    #显示当前的Git配置
    git config --list           
    #编辑配置文件
    git config -e [--global]  
    # 设置提交代码时的用户信息
    git config [--global] user.name "[name]"   

    三、提交、缓存

    #添加文件到缓存区
    git add <pathspec>
    #把添加到缓存区的文件恢复到工作区
    git reset <pathspec>
    #恢复到commandid提交点,可用于撤销commit,reset后提交git push origin HEAD --force
    git reset --hard <commandid>
    #从版本仓库中删除某个文件;-cached只删除版本信息但是不删除文件
    git rm <pathspec>
    #把当前工作区的改动压入储存栈
    git stash            
    # 把当前工作区的改动压入储存区;name是要保存的名字
    git stash save <name>    
    #把最后一个储存区的记录出栈
    git stash pop          
    #应用最后一个储存区的记录,但是不出栈
    git stash apply         
    #查看储存列表
    git stash list           
    # 提交文件到本地仓库区
    git commit <pathspec> -m 'message'      
    # 提交所有改动
    git commit -a                               
    #使用新的提交代替上一次提交
    git commit --amend -m 'message'        

    四、拉取推送

    #推送提交到远程仓库
    git push                  
    #拉取远程仓库代码
    git pull              
    #通过奠基方式拉取远程仓库代码
    git pull --rebase        
    # 如果git pull --rebase有冲突 ,解决冲突后继续rebase
    git rebase --continue 

    五、分支

    #在当前分支上创建test分支 创建完后需要push
    git branch test              
    #创建并切换到test分支  
    git brach -b test
    #推送本地分支到远程
    git push origin localbranch:remotebranch  
    #从commit处创建一个分支
    git branch [branchname] [commit] 
    #切换分支    
    git checkout test          
    #删除分支 ,删除后需要push
    git branch -d test
    #删除远程分支 
    git push origin --delete [branchname] 
    #合并指定的分支到当前分支但不提交
    git merge [branchname] - - no-commit
    #删除tag git push origin
    --delete tag <tagname>
  • 相关阅读:
    使用模拟器混淆前端代码
    中间人攻击 -- Cookie 喷发
    【探索】机器指令翻译成 JavaScript
    复杂的 Hash 函数组合有意义吗?
    【探索】利用 canvas 实现数据压缩
    【趣事】用 JavaScript 对抗 DDOS 攻击 (下)
    【趣事】用 JavaScript 对抗 DDOS 攻击
    【探索】在 JavaScript 中使用 C 程序
    【探索】无形验证码 —— PoW 算力验证
    对抗明文口令泄露 —— Web 前端慢 Hash
  • 原文地址:https://www.cnblogs.com/shuigu/p/6179417.html
Copyright © 2011-2022 走看看