zoukankan      html  css  js  c++  java
  • git常用命令总结

    初始化Git:

    git init

    克隆远程资源到本地:

    git clone url

    查看分支:

    //查看本地当前所有分支:

    git branch -a

     

    //查看本地各分支最新提交

    git branch -v

     

    //查看远程当前所有分支

    git branch -r

     

    //查看远程各分支最新提交

    git branch -r -v

    //查看本地分支和远程分支的映射关系

    git branch -vv

    新建分支:

    //本地新建分支

    git checkout -b branchName

     

    //将本地新建分支推送到远程

    git push origin branchName

     

    //创建远程分支(远程无分支)

    git push origin branchName:branchName

    合并分支:

    //先切换到master分支上

    git merge 次分支名

    查看合并后状态:

    git status

    删除分支:

    //删除远程分支

    git push origin -delete branchName

     

    //删除本地已经合并的分支

    git branch -d branchName

     

    //删除本地未合并的分支

    git branch -D branchName

    与远程分支做关联(远程已有分支,但没有和本地分支关联):

    注意:本地必须先切换到需要与远程关联的分支上

    git push -u origin/branchName

    将本地分支与远程分支链接:

    git branch -u origin/ remoteBranchName localBranchName

    注意:如果出现以下错误,按如下操作:

     

    1.先测试新建分支可否使用(如果出现Already up to date则代表成功)

    git pull

     

    2.如报错,执行以下命令

    将当前分支与远程分支关联

    git branch –set—upstream-to=origin/remoteBranchName localBranchName

    提交到暂存区:

    git add .

    提交到本地仓库:

    git commit -m “Description”

    下拉同步远程仓库:

    git pull origin remoteBranchName

    提交推送到远程仓库:

    git push origin remoteBranchName

    git push origin localBranchName:remoteBranchName

    冲突问题解决:

    1.将本地代码回滚至上一次提交的时候(无本次新增与修改)

    git stash

     

    2.将远程代码拉取下来与本地同步

    git pull origin remoteBranchName

     

    3.将第一步回滚的代码释放出来(将修改的代码与拉取的最新代码合并)

    git stash pop

     

    4.提交暂存区

    git add .

     

    5.提交本地仓库

    git commit -m “描述信息

     

    6.推送到远程仓库

    git push origin remoteBranchName

    git push origin localBranchName:remoteBranchName

     

    7.再次拉取(避免代码不是最新的问题)

    git pull origin remoteBranchName

  • 相关阅读:
    (OK) angular2-data-table is a Angular2 component for presenting large and complex data.
    Table pagination and Search bar in Angular2
    Angular 2 Tutorial: Create a CRUD App with Angular CLI and TypeScript
    Angular 2 CRUD application using Nodejs
    kernel 3.10内核源码分析--BUG_ON流程
    Protecting Routes using Guards in Angular 2
    Angular 2 User Registration and Login Example & Tutorial
    dmidecode
    (half OK) 在VirtualBox中运行 cm-13-kiwi (华为 荣耀 5X)
    Linux基金会宣布成立OpenSDS组织,应对存储云化转型
  • 原文地址:https://www.cnblogs.com/lyy0622/p/13953530.html
Copyright © 2011-2022 走看看