如何创建本地git分支到远程
创建本地分支到远程:
1.$git init 之后创建的本地仓库默认master分支
如果现在就要$ git branch 查看当前分支,是不显示任何分支的,只有在add,commit文件之后才显示,
比如:
$ git init
$ git branch(master分支也不显示)
$ git add a1.txt
$ git commit -m 'a1 file'
$ git branch(显示master分支)
所以,只有commit之后才能显示master分支,
之后添加的分支,要是查看的话也能查看到。
2.在本地分支master上创建子分支dev(命令:如果要创建分支:git branch dev 切换分支:$ git checkout dev)
$ git checkout -b dev(创建并切换)
用git branch命令查看当前分支,可以看到当前的分支是dev

3.此时,dev分支下的内容是继承master的,所以也就继承了master分支的a1.txt,
此时的a1.txt:111111
在这里试着修改a1.txt的内容,修改为 111111
222222
4.传修改的a1.txt到远程仓库(此时dev分支上的a1就是修改好了的a1.txt)
$ git add a1.txt
$ git commit -m'dev'
$ git push origin dev

5.创建dev分支下的分支hello,即hello分支继承dev分支下的a1.txt文件):
$ git checkout -b hello
git push origin hello

6.如果说还是想在master下创建分支,那么先切换到master分支上,再创建分支(以master为基础,继承master的文件)
$ git checkout master
$ git branch mhello
$ git push origin mhello

如何创建本地git分支到远程的更多相关文章
- 创建本地Git并提交到码云
概述 安装Git,使用Git Bash创建本地Git全局用户名,提交远程代码时将以此用户名显示git config --global --replace-all user.email "it ...
- 【git】本地git bash连接远程库github
重要参考: https://www.liaoxuefeng.com/wiki/896043488029600 https://segmentfault.com/a/1190000003728094 正 ...
- git拉取远程分支到本地分支或者创建本地新分支
git fetch origin branchname:branchname 可以把远程某各分支拉去到本地的branchname下,如果没有branchname,则会在本地新建branchname g ...
- 本地Git仓库和远程仓库的创建及关联
新建一个远程的仓库(空的) 新建一个远程仓库 设置远程仓库的名字,并创建 设置仓库名 切记:如果我们在创建远程仓库的时候添加了README和.ignore等文件,我们在后面关联仓库后,需要先执行pul ...
- 更新本地git仓库的远程地址(remote地址)
如果远程仓库的地址更新了,我们本地仓库就需要更新remote地址, 可以通过git remote -v或者cat .git/config查看通信方式及远程地址 更新远程地址的方式有两种: 第一种方式: ...
- git克隆远程项目并创建本地对应分支
http://jingyan.baidu.com/article/19192ad83ea879e53e5707ce.html
- Git创建本地仓库、与远程仓库关联
不知道对不对,不过我这么干能用了嘿嘿 下载好git以及配置密钥什么的就不说了,网上一p眼子 在本地找个变成仓库的文件夹,打开git命令行工具cd到这个目录,然后git init创建本地仓库 然后上gi ...
- git基于master创建本地新分支
应用场景:开发过程中经常用到从master分支copy一个本地分支作为开发分支 步骤: 1.切换到被copy的分支(master),并且从远端拉取最新版本 $git checkout master $ ...
- Git分支(远程)
1.远程分支的表示形式:远程仓库名称/分支名,如:origin/master: 2.一次Git克隆会建立你自己的本地分支:master和远程分支:origin/master,它们都指向origin ...
随机推荐
- 【建议收藏】swoft的最佳实践
这是一篇使用 swoft 两个月后的总结文章!,后续会陆续更新的 这是 web-api 开发的总结,如果使用 websocket 等服务的可能不适用,本章节会对一些规范.习惯,或者优化进行一些说明 一 ...
- 前端面试?这份手撸Promise请你收下
前言 现在很多大厂面试前端都会要求能够手动的写出一个Promise,所以这里整理了一份手写的Promise. 绝对详细,功能绝对强大.如果你不了解Promise的基本使用,那么本篇文章可能不太适合你, ...
- 遍历数组,对象和JSON
遍历数组 var arr2 = [3,4,5,6,7,8]; //第一种方法 for(var i =0;i<arr.length;i++){ console.log(arr2[i]); } // ...
- asp.net core 应用docke部署到centos7
前言 前期准备 win10 (不要安装hyper-V) VMware-Workstation-Pro/15.0 Xshell6 (非必需) VS2019 以上环境请自行安装 都是默认安装没什么可说的 ...
- 编译Uboot时出错:【已解决】 /bin/bash: arm-linux-gcc: command not found dirname: missing operand Try 'dirname --help' for more information.
编译Uboot时出错: 错误信息如下: /bin/bash: arm-linux-gcc: command not found dirname: missing operand Try 'dirnam ...
- 秒杀 2Sum 3Sum 4Sum 算法题
2 Sum 这题是 Leetcode 的第一题,相信大部分小伙伴都听过的吧. 作为一道标着 Easy 难度的题,它真的这么简单吗? 我在之前的刷题视频里说过,大家刷题一定要吃透一类题,为什么有的人题目 ...
- install-newton部署安装--------计算节点部署安装
#################################################################################################### ...
- Leetcode 24. Swap Nodes in Pairs(详细图解一看就会)
题目内容 Given a linked list, swap every two adjacent nodes and return its head. You may not modify the ...
- in文件注意事项及详细解释(转载)
转载自:https://www.cnblogs.com/sysu/p/10817315.html 和 https://www.cnblogs.com/panscience/p/4953940.h ...
- python实例 三国人物出场次序 jieba库
#Cal3kingdoms.py import jieba txt = open("threekingdoms.txt", "r", encoding=&quo ...