zoukankan      html  css  js  c++  java
  • git拉取远程分支并创建本地分支

    本地分支推送至远程

    git checkout local_branch
    git push origin local_branch:remote_branch

    一、查看远程分支

    使用如下Git命令查看所有远程分支:

    git branch -r

    列出本地分支:

    git branch

    删除本地分支:

    git branch -D BranchName

    其中-D也可以是--delete,如:

    git branch --delete BranchName

     删除本地的远程分支:

    git branch -r -D origin/BranchName

    远程删除git服务器上的分支:

    git push origin -d BranchName

    其中-d也可以是--delete,如:

    git push origin --delete BranchName

    二、拉取远程分支并创建本地分支

    方法一

    使用如下命令:

    git fetch
    git branch -r
    git checkout -b fenzhi001 origin/fenzhi001

    git checkout -b 本地分支名x origin/远程分支名x

    使用该方式会在本地新建分支x,并自动切换到该本地分支x。

    方式二

    使用如下命令:

    git fetch origin fenzhi001:fenzhi001

    git checkout fenzhi001

    使用该方式会在本地新建分支x,但是不会自动切换到该本地分支x,需要手动checkout

     

    在项目中使用Submodule

    使用git命令可以直接添加Submodule:

    git submodule add 地址 目录名

    git submodule add git@github.com:jjz/pod-library.git common

    使用 git status命令可以看到

    git status

        On branch master

        Changes to be committed:

        

            new file:   .gitmodules

            new file:   common

     

    可以看到多了两个需要提交的文件:.gitmodules和 common 

    .gitmodules 内容包含Submodule的主要信息,指定reposirory,指定路径:

       [submodule "pod-library"]

            path = common

            url = git@github.com:jjz/pod-library.git

     

    发布子模块改动

    git push --recurse-submodules=check 

    或者

    git push --recurse-submodules=on-demand

  • 相关阅读:
    saltstack(master迁移)
    saltstack(主机改名)
    saltstack-部署
    redis部署
    lvs+keepalived
    android适应屏幕
    Android 网络编程
    使用pdb调试python
    python zookeeper 学习笔记
    Python 守护进程
  • 原文地址:https://www.cnblogs.com/mmykdbc/p/9076199.html
Copyright © 2011-2022 走看看