zoukankan      html  css  js  c++  java
  • 项目中常用的一些git指令

    项目中常用的一些git指令

    1. 新建一个本地分支并切换到新建的那个分支

      git checkout -b  (新分支名)
      
    2. 从一个分支切换到另一个分支:

      git checkout 分支名
      
    3. 将代码恢复到最近的一次commit 时候的状态:

      git stash
      
    4. 将代码从最近的一次commit的状态恢复到最新的进度:

      git stash pop
      
    5. 将一个本地子分支合并到本地的master分支:

      先将分支切换到master分支,然后执行:

      git merge 将要合并的子分支
      
    6. 回退到某一次commit状态

      git reset --hard commit的id
      

      如果想要回退到上一个commit,同时要保留上一个commit之后新添加的内容,需要使用

      git reset --soft commit的id
      
    7. 添加一个远程git仓库

      git remote add 别名 git仓库地址
      
    8. 删除一个本地分支

      git  branch -D 本地分支名
      
    9. git add 添加错文件后撤销操作

      git reset HEAD 被错误添加的文件名
      

      如果git reset HEAD后面什么都不加,就撤销上一次git add的全部内容

    10. 使远端仓库回退到本地的commit状态:

      git push origin <分支名> --force
      
    11. 更改本地分支的名字

      git branch -m oldName newName
      
    12. 创建一个本地分支,并将该分支和远端的一个子分支联系起来

      git checkout -b 本地分支名 origin/远程分支名
      
  • 相关阅读:
    CF1454F Array Partition
    leetcode1883 准时抵达会议现场的最小跳过休息次数
    leetcode1871 跳跃游戏 VII
    leetcode1872 石子游戏VIII
    CF1355C Count Triangles
    CF1245D Shichikuji and Power Grid
    CF1368C Even Picture
    CF1368D AND, OR and square sum
    CF1395C Boboniu and Bit Operations
    SpringBoot和开发热部署
  • 原文地址:https://www.cnblogs.com/Mortallin/p/13804711.html
Copyright © 2011-2022 走看看