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

    新建分支

    1  // 新建本地分支并切换到新分支
    2 git checkout -b dbg_lichen_star
    3 // 推送新分支到远程
    4 git push origin dbg_lichen_star:dbg_lichen_star
    5 // 删除远程分支
    6 // 方法一
    7 git push origin :dbg_lichen_star
    8 // 方法二
    9 git push origin --delete dbg_lichen_star

    修改分支

    1 git branch -m old_branch new_branch # Rename branch locally 
    2 git push origin :old_branch # Delete the old branch 
    3 git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote

    pull拉取特定分支代码

    1、将远程指定分支 拉取到 本地指定分支上:

    git pull origin <远程分支名>:<本地分支名>

    2、将远程指定分支 拉取到 本地当前分支上:

    git pull origin <远程分支名>

    3、将与本地当前分支同名的远程分支 拉取到 本地当前分支上(需先关联远程分支)

    git pull origin

    在克隆远程项目的时候,本地分支会自动与远程仓库建立追踪关系,可以使用默认的origin来替代远程仓库名,
    所以,我常用的命令就是 git pull origin <远程仓库名>,操作简单,安全可控。

    push操作

    1、将本地当前分支 推送到 远程指定分支上(注意:pull是远程在前本地在后,push相反):

    git push origin <本地分支名>:<远程分支名>

    2、将本地当前分支 推送到 与本地当前分支同名的远程分支上(注意:pull是远程在前本地在后,push相反):

    git push origin <本地分支名>

    3、将本地当前分支 推送到 与本地当前分支同名的远程分支上(需先关联远程分支)

    git push origin

    同样的,推荐使用第2种方式,git push origin <远程同名分支名>

    附:

    // 将本地分支与远程同名分支相关联

    git push --set-upstream origin <本地分支名>

    参考文档 https://blog.csdn.net/u010059669/article/details/82670484

  • 相关阅读:
    docker 安装镜像
    Vagrant+Oracle VM VirtualBox创建linux虚拟机(centos7)
    idea配置git,github , gitee
    idea连接数据库
    idea基本设置
    git基础命令
    mybatis中的where
    重学 Java 设计模式:实战桥接模式(多支付渠道「微信、支付宝」与多支付模式「刷脸、指纹」场景)
    HTTPS加密原理
    优惠券数据库设计
  • 原文地址:https://www.cnblogs.com/1032473245jing/p/11376238.html
Copyright © 2011-2022 走看看