git 常用命令-以及命令解析

一、Push操作

  • 1.先git init
    • 标识仓库地址
  • 2.git add xxx
    • git add .
      • 代表添加当前目录所有文件
    • 代表标识提交的文件
  • 3.git commit -m 'xxxx'
    • 代表git提交后需要说的什么话
  • 4.git remote add origin xxxx
    • xxxx替换为github仓库的ssh地址
  • 5.git push origin xxx
    • xxx为分支名称
    • 如果有报错可以通过
      • git checkout -b 加分支名称
      • 进行检查

二、其他命令解析

  • git命令解析
    • git clone + url
      • 克隆项目文件夹
    • git init
      • git init #初始化仓库
        *
      • 会在执行这条命令的目录下生产.git目录
        • 隐藏的
        • 由这个目录表示这个是仓库
    • git status
      • 展示仓库新增或修改
    • 2.git add + . 或 ./
      • 代表把文件加入到购物车
        • 暂存区
      • 即代表即将提交那些文件
      • .代表当前所有文件
    • git reset
      • 将暂存区的文件移除暂存区
    • 3.git commit
      • git commit 命令将暂存区内容添加到本地仓库中。
        • 只提交绿色了的文件
      • -a 参数设置修改文件后不需要执行 git add 命令,直接来提交
      • git commit -m [message]
        • 例如
          • git commit -m 'demo commit'
          • 添加提交信息
            • 例如"第一次提交等等"
    • git logs
      • 查看commit日志
    • 4.git remove
    • 5.git push
      • git push 命令用于从将本地的分支版本上传到远程并合并。
      • github从master变成了main
        • 主分支
      • git push origin main
        • 命令将本地的 master 分支推送到 origin 主机的 master 分支。
        • main
          • 主干
        • master
          • 主干
    • git clone
      • git clone -b master git@github.com:kodyssss/deploy-xt-cloud.git
      • -b
        • 拉取指定分支项目
    • git hub token
      • github_username: 974177019@qq.com

        github_password: P@sswr0dss

        github_push_token: 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

  • init操作
    • echo "# xt-cloud-deploy" >> README.md
      git init
      git add README.md
      git commit -m "first commit"
      git branch -M main
      git remote add origin git@github.com:kodyssss/xt-cloud-deploy.git
      git push -u origin main
    • git remote add origin git@github.com:kodyssss/xt-cloud-deploy.git
      git branch -M main
      git push -u origin main
  • git排错
    • 解决GitHub报错You're using an RSA key with SHA-1, which is no longer allowed. Please use a newer client
      • 原因:git 认为rsa的密钥不安全
      • 解决办法:1.需要修改算法
      • 2.把生成的ed25519.pub放到git hub
  • git使用443 clone项目
相关推荐
sulikey5 小时前
从入门到精通:如何自己编写高质量的 .gitignore(面向工程实践)
git·gitee·编辑器·gitlab·github·gitignore·gitattributes
青靴8 小时前
轻量级 CI/CD:Git Hooks 自动部署 Node.js 应用(CICD-demo)
git·ci/cd·node.js
哟哟耶耶10 小时前
git-git cherry-pick(从分支挑选特定提交-哈希值)更改应用到当前分支
git
无限进步_11 小时前
C语言动态内存管理:掌握malloc、calloc、realloc和free的实战应用
c语言·开发语言·c++·git·算法·github·visual studio
程序员馨馨15 小时前
git常用命令学习以及冲突解决
git·功能测试·学习
1***81531 天前
Git游戏开发案例
git
likuolei1 天前
Git 工作区、暂存区和版本库
数据库·git
HAPPY酷1 天前
git配置及使用
git
sg_knight1 天前
IntelliJ IDEA 实用插件:GitToolBox 使用指南
java·ide·git·intellij-idea·插件·gittoolbox
青靴1 天前
Git Hooks 实现 CI/CD 进阶实践 -- 根据实际需求添加功能
git·elasticsearch·ci/cd