git常用命令大全

  1. git init:初始化一个新的 Git 仓库。

    git init
    
  2. git clone:克隆远程仓库到本地。

    git clone <repository_url>
    
  3. git add:将文件添加到暂存区。

    git add <file_name>
    
  4. git commit:将暂存区中的文件提交到本地仓库。

    git commit -m "Commit message"
    
  5. git push:将本地仓库的变更推送到远程仓库。

    git push origin <branch_name>
    
  6. git pull:从远程仓库拉取最新的变更并合并到本地仓库。

    git pull origin <branch_name>
    
  7. git branch:管理分支。

    git branch                        # 列出所有分支
    git branch <branch_name>          # 创建新分支
    git branch -d <branch_name>       # 删除分支
    
  8. git checkout:切换分支或还原文件。

    git checkout <branch_name>        # 切换分支
    git checkout -- <file_name>       # 还原文件到最近一次提交的状态
    
  9. git merge:合并指定分支到当前分支。

    git merge <branch_name>
    
  10. git status:查看仓库当前的状态。

    git status
    
  11. git log:查看提交历史。

    git log
    
  12. git remote:管理远程仓库。

    git remote -v                    # 查看远程仓库列表
    git remote add <name> <url>      # 添加远程仓库
    
  13. git reset:重置当前分支的 HEAD 到指定状态。

    git reset --hard <commit_hash>   # 重置到指定提交
    
  14. git stash:暂存当前工作目录的变更。

    git stash                        # 暂存变更
    git stash apply                  # 恢复暂存的变更
    
  15. git tag:管理标签。

    git tag                         # 列出所有标签
    git tag <tag_name>              # 创建新标签
    

这些是 Git 中常用的一些命令,覆盖了版本控制、分支管理、远程仓库操作等多个方面。

  • 6
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值