Git_Git远程操作_第2课_Git远程协作的主要命令
2016-09-23 11:25
369 查看
讲解的命令:
git remote
git clone
git fetch
git pull
git push
================================
命令:git remote
#增加远程仓库
git remote add origin git@github.com:michaelliao/learngit.git
================================================
命令: git clone
git clone 支持协议有 ssh, http , git ...
========================
命令: git fetch
#获取远程的所有分支和数据
git fetch
示例:
git fetch
#用远程跟踪分支合并本地当前分支
git merge origin/master
#只更新指定分支的信息
git fetch origin branchName
#用/origin/master 更新 本地 master 信息,需要merge
git fetch origin master:remotes/origin/master
tips:
git无法pull仓库refusing
to merge unrelated histories 解决方案
因为他们是两个不同的项目,要把两个不同的项目合并,git需要添加一句代码,在
假如我们的源是origin,分支是master,那么我们 需要这样写
=====================
命令: git pull
#git pull 相当于 git fetch 与 git merge 的混合体
git pull
#只更新单独的一个分支
git pull origin branchName
#将远程的branch与 本地的localBranchName进行绑定
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> localBranchName
=========================
命令: git push
#推送本地的tag到远程仓库中
git push --tags
#仅推送本地master分支的内容
git push origin master
#删除远程分支 && 并删除本地该分支
方法一
git branch -d branchName #先删除本地分支
git push --delete origin branchName #再推送删除远程分支
方法二
git branch -d branchName #先删除本地分支
git push origin :branchName(remote) #以空分支替代远程的分支
=====配置本地库与远程库的对应关系===
#较为复杂的一种配置
git push origin master:qa/master 将本地的master分支 推送到 远程的qa/master上
#或者直接修改配置local的配置文件
#在 origin 等加上一条配置
push = refs/heads/*:refs/qa/*
git remote
git clone
git fetch
git pull
git push
================================
命令:git remote
#增加远程仓库
git remote add origin git@github.com:michaelliao/learngit.git
================================================
命令: git clone
git clone 支持协议有 ssh, http , git ...
========================
命令: git fetch
#获取远程的所有分支和数据
git fetch
示例:
git fetch
#用远程跟踪分支合并本地当前分支
git merge origin/master
#只更新指定分支的信息
git fetch origin branchName
#用/origin/master 更新 本地 master 信息,需要merge
git fetch origin master:remotes/origin/master
tips:
git无法pull仓库refusing
to merge unrelated histories 解决方案
因为他们是两个不同的项目,要把两个不同的项目合并,git需要添加一句代码,在
git pull,这句代码是在git 2.9.2版本发生的,最新的版本需要添加
--allow-unrelated-histories
假如我们的源是origin,分支是master,那么我们 需要这样写
git pull origin master --allow-unrelated-histories需要知道,我们的源可以是本地的路径
=====================
命令: git pull
#git pull 相当于 git fetch 与 git merge 的混合体
git pull
#只更新单独的一个分支
git pull origin branchName
#将远程的branch与 本地的localBranchName进行绑定
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> localBranchName
=========================
命令: git push
#推送本地的tag到远程仓库中
git push --tags
#仅推送本地master分支的内容
git push origin master
#删除远程分支 && 并删除本地该分支
方法一
git branch -d branchName #先删除本地分支
git push --delete origin branchName #再推送删除远程分支
方法二
git branch -d branchName #先删除本地分支
git push origin :branchName(remote) #以空分支替代远程的分支
=====配置本地库与远程库的对应关系===
#较为复杂的一种配置
git push origin master:qa/master 将本地的master分支 推送到 远程的qa/master上
#或者直接修改配置local的配置文件
#在 origin 等加上一条配置
push = refs/heads/*:refs/qa/*
相关文章推荐
- git 远程协作的主要命令
- 9、Git远程协作的主要命令
- git 的使用——基本的仓库创建,文件提交,上传操作命令,远程仓库关联
- git远程操作repository的几个命令
- Git进阶命令(三)之Git远程仓库操作
- 一、Git的一些命令操作----创建版本库、增加文件到Git库、时光机穿梭、远程仓库
- Git远程协作开发通用操作
- [cnblogs镜像]Github 团队协作基本流程与命令操作 图解git工作流程
- git远程操作常用命令
- Git总结(1)—优势&安装&原理&本地操作命令&分支&协作&标签&自定义配置
- git入门-----远程操作相关命令(remote 、push、fetch 、pull)
- Git常用命令——远程操作
- git命令与github使用(转主要看向远程仓库推内容)
- Git主要命令操作详解
- Github 团队协作基本流程与命令操作 图解git工作流程
- Git clone远程分支等分支操作命令
- Git学习笔记(5)----基本操作及命令(远程仓库篇)
- git远程操作常用命令
- Git命令的使用_操作远程仓库——详细教程3
- Git命令操作远程仓库分支和本地仓库分支