美文网首页
git 常见操作

git 常见操作

作者: jiaxiaolei | 来源:发表于2022-06-01 19:18 被阅读0次

    git 代码的本地修改:

    image.png

    删除远端分支:

    ➜  jia_lenovo_vmha git:(my_dev) git push origin --delete my_dev
    To git@github.com:jiaxiaolei/vmha.git
     - [deleted]         my_dev
    

    本地分支要和远端对应起来...

     ➜  jia_lenovo_vmha git:(dev) ✗ git push
     fatal: The current branch dev has no upstream branch.
     To push the current branch and set the remote as upstream, use
    
         git push --set-upstream origin dev
    
    ➜  jia_lenovo_vmha git:(dev) ✗ git push --set-upstream origin dev
    Branch dev set up to track remote branch dev from origin by rebasing.
    Everything up-to-date
    

    删除本地分支

    $ git branch -d <BranchName>
    

    merge 代码:

    准备合并dev分支,请注意--no-ff参数,表示禁用Fast forward:
    
    $ git merge --no-ff -m "merge with no-ff" dev
    Merge made by the 'recursive' strategy.
     readme.txt | 1 +
     1 file changed, 1 insertion(+)
    
    因为本次合并要创建一个新的commit,所以加上-m参数,把commit描述写进去。
    
    合并后,我们用git log看看分支历史:
    
    $ git log --graph --pretty=oneline --abbrev-commit
    *   e1e9c68 (HEAD -> master) merge with no-ff
    |\  
    | * f52c633 (dev) add merge
    |/  
    *   cf810e4 conflict fixed
    ...
    可以看到,不使用Fast forward模式,merge后就像这样:
    
    
    

    相关文章

      网友评论

          本文标题:git 常见操作

          本文链接:https://www.haomeiwen.com/subject/synfzctx.html