git command
下载github代码
git clone https://github.com/zhoug2020/2015.git
在github上创建仓库:
Create a new repository on the command line
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/BrentHuang/MyRepo.git
git push -u origin master
在本地新建一个分支: git branch Branch1
切换到你的新分支: git checkout Branch1
将新分支发布在github上: git push origin Branch1
在本地删除一个分支: git branch -d Branch1
在github远程端删除一个分支: git push origin :Branch1 (分支名前的冒号代表删除)
直接使用git pull和git push的设置
git branch --set-upstream-to=origin/master master
git branch --set-upstream-to=origin/ThirdParty ThirdParty
git config --global push.default matching
新建好的代码库有且仅有一个主分支(master),它是自动建立的。
可以新建分支用于开发:
git branch develop master
新建一个叫develop的分支,基于master分支
切换到这个分支:
git checkout develop
现在可以在这个develop分支上做一些改动,并且提交。
注意:切换分支的时候可以发现,在Windows中的repository文件夹中的文件内容也会实时相应改变,变成当前分支的内容。
push方法1:
现在如果想直接Push这个develop分支上的内容到github
git push -u origin
如果是新建分支第一次push,会提示:
fatal: The current branch develop has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin develop
输入这行命令,然后输入用户名和密码,就push成功了。
以后的push就只需要输入git push origin
push方法2:
比如新建了一个叫dev的分支,而github网站上还没有,可以直接:
git push -u origin dev
这样一个新分支就创建好了。
push方法3:
提交到github的分支有多个,提交时可以用这样的格式:
git push -u origin local:remote
比如:git push -u origin master:master
表明将本地的master分支(冒号前)push到github的master分支(冒号后)。
如果左边不写为空,将会删除远程的右边分支。
创建分支的另一种方法
用命令git checkout -b develop2 develop
可以新建一个分支develop2,同时切换到这个分支
删除分支
git branch可以查看所有的分支
git branch -d develop2 将develop2分支删除
Clone
使用git clone+github地址的方法,项目默认只有master分支。git branch也只有master
要看所有的分支:git branch -a或者是git branch -r
这时候要新建一个分支,叫做dev,基于远程的dev分支:git checkout -b dev origin/dev
加Tag
git tag tagname develop
git tag中的两个参数,一个是标签名称,另一个是希望打标签的点develop分支的末梢。
合并分支
git checkout master
先转到主分支
git merge --no-ff develop
然后把develop分支merge过来
参数意义:
不用参数的默认情况下,是执行快进式合并。
使用参数--no-ff,会执行正常合并,在master分支上生成一个新节点。
merge的时候如果遇到冲突,就手动解决,然后重新add,commit即可。
git command的更多相关文章
- [Tool] SourceTree初始化GitFlow遇到错误(git command not found)的解决方案
[Tool] SourceTree初始化GitFlow遇到错误(git command not found)的解决方案 问题情景 使用SourceTree,可以方便开发人员快速的套用GitFlow开发 ...
- Cordova 3.0 Plugin 安装 及"git" command line tool is not installed
根据http://docs.phonegap.com/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface Windows命令行 ...
- [Practical Git] Navigate git command pager output with Unix less commands
When using a git command that can have a large amount of output (like git log, git diff, or git blam ...
- git: command not found
在使用git时,出现“git: command not found”的情况,于是使用yum安装: [root@localhost ~]# yum install -y gitLoaded plugin ...
- 警告: git command could not be found. Please create an alias or add it to yo
5 Answers active answertab=oldest#tab-top" title="Answers in the order they were provided& ...
- Git Command之Code Review
原文链接 准备 Step 1. Create a team and add a teammate Step 2. Create a repository with some content 应用 Cl ...
- git command line 提交代码
echo "# spring-boot-apollo-demo" >> README.md git init git add README.md git commit ...
- 解决git: 'subtree' is not a git command. See 'git --help'.
一.第一方法 git clone https://github.com/git/git.git cd git/contrib/subtree sudo make prefix=/usr sudo ma ...
- fuck--Fix git command line spelling errors GitHub
修复Git输入错误,挺有意思.git命令关键字如果输入错误,会提示最接近的正确关键字,如果提示内容是你想要的,输入'fuck',就能执行了. GitHub源码.源码生成exe,windows上运行. ...
随机推荐
- DIV CSS设计时IE6、IE7、FF 与兼容性有关的特性(转载的)
在网站设计的时候,应该注意css样式兼容不同浏览器问题,特别是对完全使用DIV CSS设计的网,就应该更注意IE6 IE7 FF对CSS样式的兼容,不然,你的网乱可能出去不想出现的效果! 所有浏览器 ...
- JavaScript获取DOM元素位置和尺寸大小
在一些复杂的页面中经常会用JavaScript处理一些DOM元素的动态效果,这种时候我们经常会用到一些元素位置和尺寸的计算,浏览器兼容性问题也是不可忽略的一部分,要想写出预想效果的JavaScri ...
- LaTeX新人教程,30分钟从完全陌生到基本入门
by Nan 对于真心渴望迅速上手LaTeX的人,前言部分可以跳过不看. 本教程面向对LaTeX完全无认知无基础的新人.旨在让新人能够用最简单快捷的方式,轻松入门,能够迅速使用LaTeX完成基本的文本 ...
- 同一Session中的aspx页面的并发限制
项目中客户端采用WebBrowser展示aspx页面,用户有可能打开带多个带WebBrowser的winform窗体.此时,如果其中一个的WebBrowser的aspx页面响应较长的话,其他窗体中的W ...
- Android之网络请求库
自己学习android也有一段时间了,在实际开发中,频繁的接触网络请求,而网络请求的方式很多,最常见的那么几个也就那么几个.本篇文章对常见的网络请求库进行一个总结. HttpUrlConnection ...
- python之for学习
for i in range(100,-1,-1): print "%s\n"%i; import os path = 'D:\\Test' for root, ...
- asp数据链接
asp页面的中的数据库连接要进行唯一名称处理,不然页面中多个连接使用时,会出现连接莫名关闭.数据不能写入,但是页面也没报错.asp可以将有数据库连接的地方,提取成单独的函数.在每个方法单独命名数据库连 ...
- 关于结构化BOM的思考
参加了今天的"自主生产音箱类产品BOM结构问题"(即非采购而是制造的音箱)会议,我发现大家在会议上呈现的产品结构对生产计划的层级需求已上升到5层的需求了,又找段会胜要了各位前期就此 ...
- 巧用ifstream判断文件是否存在
最近在写手写数字的识别软件,训练样例数量巨大而且数字个数不唯一,有可能在中途粘出一部分做测试样例.因此写下面的脚本来获取文件名,之后丢到训练函数里. #include <algorithm> ...
- 指针数组vs数组指针 指针函数vs函数指针
在分辨这些重要的概念时,我们先回顾一下前面所讲的C之三值合一,由于三个值所求出的地址是相同的,所以经常有传言说他们都是首元素的地址.这种说法是不正确的.为什么说它是不正确的呢? 首先定义一个指针,将三 ...