zoukankan      html  css  js  c++  java
  • 在git的branch上工作

    How to clone all remote branches in Git?

    First, clone a remote Git repository and cd into it:

    $ git clone git://example.com/myproject
    $ cd myproject
    

    Next, look at the local branches in your repository:

    $ git branch
    * master
    

    But there are other branches hiding in your repository! You can see these using the -a flag:

    $ git branch -a
    * master
      remotes/origin/HEAD
      remotes/origin/master
      remotes/origin/v1.0-stable
      remotes/origin/experimental
    

    If you just want to take a quick peek at an upstream branch, you can check it out directly:

    $ git checkout origin/experimental
    

    But if you want to work on that branch, you'll need to create a local tracking branch which is done automatically by:

    $ git checkout experimental
    

    and you will see

    Branch experimental set up to track remote branch experimental from origin.
    Switched to a new branch 'experimental'
    

    That last line throws some people: "New branch" - huh? What it really means is that the branch is taken from the index and created locally for you. The previous line is actually more informative as it tells you that the branch is being set up to track the remote branch, which usually means the origin/branch_name branch

    Now, if you look at your local branches, this is what you'll see:

    $ git branch
    * experimental
      master
    

    You can actually track more than one remote repository using git remote.

    $ git remote add win32 git://example.com/users/joe/myproject-win32-port
    $ git branch -a
    * master
      remotes/origin/HEAD
      remotes/origin/master
      remotes/origin/v1.0-stable
      remotes/origin/experimental
      remotes/win32/master
      remotes/win32/new-widgets
    

    At this point, things are getting pretty crazy, so run gitk to see what's going on:

    $ gitk --all &
  • 相关阅读:
    java8 list 删除元素 简单版
    java8 list 删除元素 结构复杂版
    xshell 连接 centos 中的 vi 配色
    Redis 运行出错
    电脑清理秘籍 [ 精心总结 ]
    团队项目之后的反思
    团队项目心得 [ 感想 ]
    团队项目心得 [ 第二阶段项目总结 ]
    团队项目心得 [ 第一阶段项目总结 ]
    《创新者》读书笔记
  • 原文地址:https://www.cnblogs.com/andy-0212/p/11599831.html
Copyright © 2011-2022 走看看