zoukankan      html  css  js  c++  java
  • git操作回顾:

    1. git查看自己的本地分支:

      

    ***:~/mysite/mysite$ git branch 
    * master

    2. 查看远程分支:

      

    ***:~/mysite/mysite$ git branch -a
    * master
      remotes/origin/HEAD -> origin/master
      remotes/origin/master
      remotes/origin/wyl

    3. 创建自己的本地分支:

      

    ***:~/mysite/mysite$ git branch luoting
    
    ***:~/mysite/mysite$ git branch 
      luoting
    * master

    4. 切换到分支:

      

    ***:~/mysite/mysite$ git branch 
      luoting
    * master
    
    ***:~/mysite/mysite$ git checkout luoting 

    5. 推送到远程分支:

        

    $ git push origin master 

    6. 删除本地分支   git branch -d xxxxx

      

    ***:~/mysite/mysite$ git  branch 
      luoting
    * master
    
    ***:~/mysite/mysite$ git branch -d luoting 
    已删除分支 luoting(曾为 5c404a4)。
    
    ***:~/mysite/mysite$ git branch 
    * master

    7. 使用git将远程更新到本地

      一旦远程主机的版本库有了更新(Git术语叫做commit),需要将这些更新取回本地,这时就要用到git fetch命令。

    $ git fetch <远程主机名>
    上面命令将某个远程主机的更新,全部取回本地。
    
    默认情况下,git fetch取回所有分支(branch)的更新。如果只想取回特定分支的更新,可以指定分支名。
    
    $ git fetch <远程主机名> <分支名>
    比如,取回origin主机的master分支。
    
    $ git fetch origin master
    所取回的更新,在本地主机上要用”远程主机名/分支名”的形式读取。比如origin主机的master,就要用origin/master读取。
    
    git branch命令的-r选项,可以用来查看远程分支,-a选项查看所有分支。
    
    $ git branch -r
    origin/master
    
    $ git branch -a
    * master
      remotes/origin/master
    上面命令表示,本地主机的当前分支是master,远程分支是origin/master。
    
    取回远程主机的更新以后,可以在它的基础上,使用git checkout命令创建一个新的分支。
    $ git checkout -b newBrach origin/master
    
    

    上面命令表示,在origin/master的基础上,创建一个新分支。

    
    

    此外,也可以使用git merge命令或者git rebase命令,在本地分支上合并远程分支。

    
    
    $ git merge origin/master
    # 或者
    $ git rebase origin/master
    
    

    上面命令表示在当前分支上,合并origin/master。

     
  • 相关阅读:
    LeetCode Merge Two Sorted Lists 归并排序
    LeetCode Add Binary 两个二进制数相加
    LeetCode Climbing Stairs 爬楼梯
    034 Search for a Range 搜索范围
    033 Search in Rotated Sorted Array 搜索旋转排序数组
    032 Longest Valid Parentheses 最长有效括号
    031 Next Permutation 下一个排列
    030 Substring with Concatenation of All Words 与所有单词相关联的字串
    029 Divide Two Integers 两数相除
    028 Implement strStr() 实现 strStr()
  • 原文地址:https://www.cnblogs.com/blogofwyl/p/4378128.html
Copyright © 2011-2022 走看看