zoukankan      html  css  js  c++  java
  • Git 使用总结

    Git 和svn还是比较像的

    (1)git如何提交一个文件的修改

          比如本地修改了某个文件,需要提交,文件命为a.cpp

     // 修改的注释
          >git commit -m"修改注释" a.cpp
    //最后提交到服务器  
          >git push

    (2)git 如何新增加一个文件

            比如本体新增加了某个文件,需要提交,文件命为b.cpp

    >git add b.cpp
    >git commit -m "comment" b.cpp
    >git push
    

     (3)多个文件提交,commit的后面写多个文件名,中间用空格隔开

    git commit -m "comment" b.cpp  a.cpp

     (4)放弃本地的修改 比如修改了a.cpp,别人更新过了,或者本地的代码乱了,就放弃本地修改。

    //类似svn revert 命令
    git checkout -- a.cpp 

     (5) git 添加文件夹 

       git add folder

     (6) git 提交所有修改

       git commit -a -m"comment"

     (7) git add -A

    (8) HEAD  回退的制定的版本

       git reset --hard commit_id 
       回滚到指定的版本
    git reset --hard e377f60e28c8b84158

      强制提交

    git push -f origin master
    (9) 删除分支

    Git 分支创建策略

    分支策略:git上始终保持两个分支,master分支与develop分支。master分支主要用于发布时使用,而develop分支主要用于开发使用。

    创建master的分支develop
    git checkout -b develop master

    切换到master分支
    git checkout master

    合并develop分支到master
    git merge --no-ff develop


    除了以上两个常驻分支外,我们还可以适当分支出三种分支:功能分支、预发布分支、修补分支,这三种分支使用完后也该删除,保持两个常驻分支。

    功能分支:该分支从develop中分支出来,开发完成后再合并入develop,名字采用feature-* 的形式命名。
    创建功能分支:
      git checkout -b feature-x develop
    开发完成后,合并到develop分支:
      git checkout develop
      git merge --no-ff feature-x
    最后删除分支:
      git branch -d feature-x


    预发布分支:正是版本发布前,既合并到master分支前,因此预发布分支是从develop分支出来的,预发布后,必修合并进develop和master。命名采用release-*的形式。
    创建一个预发布分支:
      git checkout -b release-* develop
    确认版本没有问题后,合并到master分支:
      git checkout master
          git merge --no-ff release-*
    对合并生成的新节点,做一个标签:
      git tag -a 1.2
    再合并到develop分支:
      git checkout decelop
      git merge --no-ff release-*
    最后删除分支:
      git branch -d release-*



    修补分支:主要用于修改bug的分支,从master分支分出来,修补后,在合并进master和develop分支。命名采用fixbug-*形式。
    创建一个修补分支:
      git checkout -b fixbug-* master
    修补结束后,合并到master分支:
      git checkout master
      git merge --no-ff fixbug-*
      git tag -a 0.1.1
    再合并到develop分支:
      git checkout develop
      git merge --no-f fixbug-*
    最后删除分支:
      git branch -d fixbug-*

     
     

       

  • 相关阅读:
    mysql中in 做条件匹配 带逗号的字符串 数据异常解决
    [LeetCode] Kth Largest Element in a Stream 数据流中的第K大的元素
    [LeetCode] Binary Search 二分搜索法
    [LeetCode] Search in a Sorted Array of Unknown Size 在未知大小的有序数组中搜索
    [LeetCode] Insert into a Binary Search Tree 二叉搜索树中插入结点
    [LeetCode] Search in a Binary Search Tree 二叉搜索树中搜索
    [LeetCode] Design Circular Deque 设计环形双向队列
    [LeetCode] Design Circular Queue 设计环形队列
    [LeetCode] N-ary Tree Preorder Traversal N叉树的前序遍历
    [LeetCode] 589. N-ary Tree Postorder Traversal N叉树的后序遍历
  • 原文地址:https://www.cnblogs.com/likwo/p/3179651.html
Copyright © 2011-2022 走看看