zoukankan      html  css  js  c++  java
  • git命令行

    1 add

    把本地代码,提交到暂存区

    //git add 文件名
    git add test.js
    
    //git add 所有修改的文件
    git add .

    2 commit 

    把暂存区代码,提交到本地git仓库

    //git commit -m "说明文字"
    git commit -m "测试"

    3 pull

    从服务器获取最新代码

    git pull
    
    //有可能需要添加远程版本库以及分支名称
    //git pull origin develop

    4 push

    把代码从本地git仓库推送到远程服务器

    git push
    
    //有可能需要添加远程版本库以及分支名称
    //git push origin develop

    5 分支

    //显示当前以及所有分支名称
    git branch
    
    //切换分支--git checkout 分支名称
    git checkout develop//这样就会切换到develop分支
    
    //创建且切换到新分支--git checkout -b 分支名称
    git checkout -b test
    
    //分支合并--git merge 要合并的分支名称(合并某分支到当前分支)
    //假设现在在develop
    git merge test
    
    //删除分支--本地删除
    //假设现在在develop,因为删除分支的时候,不能删除当前分支。所有,需要切换到develop,来删除test分支。
    git branch -d test
    //强制删除,因为有时候-d的删除方式,会提示该分支is not fully merged.
    git branch -D test  //http://blog.csdn.net/isaisai/article/details/44935653
    //把远程服务器上的分支也删除--git push origin 空格:分支名称
    git push origin :test
    
    //获取远程新的分支
    //先pull一下,就可获取远程所有分支,包括新建的分支
    git pull
    //之后,再checkout一下,检出下远程的分支名,就可以把远程分支获取到本地
    git checkout test_branch

    //把本地分支推送到远程分支
    //local_branch必须为你本地存在的分支,remote_branch为远程分支,如果remote_branch不存在则会自动创建分支
    git push origin local_branch:remote_branch

     6 克隆

    //一般克隆
    git clone git@github.com:michaelliao/gitskills.git
    
    //指定分支的克隆
    git clone git@github.com:michaelliao/gitskills.git -b [branchName]
    //如指定从develop分支克隆
    git clone git@github.com:michaelliao/gitskills.git -b develop
    

      

    可参考:

    http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

    git删除远程分支 http://www.cnblogs.com/shiningrise/archive/2013/03/12/2956779.html

    克隆:

    http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/001375233990231ac8cf32ef1b24887a5209f83e01cb94b000

    http://ask.chinaunix.net/question/1091

  • 相关阅读:
    EntityFramework之创建数据库及基本操作(一)
    Entity Framework Code First (八)迁移 Migrations
    [转]Tomcat启动报错:AnnotationConfigBeanDefinitionParser are only available on JDK 1.5 and higher
    [转]bootstrap table本地数据使用方法
    [转]MySQL-5.7 Update语句详解
    [转]操作MySQL数据库报出:Parameter index out of range (1 > number of parameters, which is
    [转]在MySQL中创建实现自增的序列(Sequence)的教程
    [转]MySQL如何设置自动增长序列 SEQUENCE
    [转]Mustache 使用心得总结
    [转]关于重定向RedirectAttributes的用法
  • 原文地址:https://www.cnblogs.com/simonbaker/p/5126961.html
Copyright © 2011-2022 走看看