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上运行. ...
随机推荐
- 【PSR规范专题(5)】PSR-4 改进后的自动加载规范
本文转自: https://github.com/PizzaLiu/PHP-FIG/blob/master/PSR-4-autoloader-cn.md 关键词 "必须"(&quo ...
- The absolute uri: http://struts.apache.org/tags-bean cannot be resolved in either web.xml or the jar files deployed with this application
在一个tomcat中部署了一个struts-1.3.10的web项目,但是没有吧struts-1.3.10的lib中的jar包放进tomcat/lib中,所以导致了这个错误(访问该项目的页面时)
- SpringMVC 中的Interceptor 拦截器
1.配置拦截器 在springMVC.xml配置文件增加: <mvc:interceptors> <!-- 日志拦截器 --> <mvc:interceptor> ...
- activeMQ主要的几类集群部署方式
官方主从实现的文档:http://activemq.apache.org/masterslave.html 一.activeMQ主要的几类部署方式比较 1.默认的单机部署(kahadb) acti ...
- USACO Section 2.3: Zero Sum
这题我做得比较麻烦,网上有个比较简单的程序. /* ID: yingzho1 LANG: C++ TASK: zerosum */ #include <iostream> #include ...
- eclipse中maven项目部署到tomcat
其实maven项目部署到tomcat的方式很多,我从一开始的打war包到tomcat/webapps目录,到使用tomcat-maven插件,到直接使用servers部署,一路来走过很多弯路. 下面就 ...
- 《OD学hadoop》在LINUX下如何将tar压缩文件解压到指定的目录下
linux下tar命令解压到指定的目录 :#tar zxvf /bbs.tar.zip -C /zzz/bbs //把根目录下的bbs.tar.zip解压到/zzz/bbs下,前提要保证存在/zzz/ ...
- STL笔记(4)关于erase,remove
STL笔记(4)关于erase,remove 你要erase的元素很容易识别.它们是从区间的“新逻辑终点”开始持续到区间真的终点的原来区间的元素.要除去那些元素,你要做的所有事情就是用那两个迭代器调用 ...
- HNOI2008题目总结
呜呼..NOI前一个月正式开始切BZOJ了……以后的题解可能不会像之前的零散风格了,一套题我会集中起来发,遇到一些需要展开总结的东西我会另开文章详细介绍. 用了一天的时间把HNOI2008这套题切了… ...
- UVa 11039 (排序+贪心) Building designing
白书上的例题比较难,认真理解样例代码有助于提高自己 后面的练习题相对简单,独立思考解决问题,增强信心 题意:n个绝对值各不相同的非0整数,选出尽量多的数排成序列,使得该序列正负交错且绝对值递增. 解法 ...