下载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的更多相关文章

  1. [Tool] SourceTree初始化GitFlow遇到错误(git command not found)的解决方案

    [Tool] SourceTree初始化GitFlow遇到错误(git command not found)的解决方案 问题情景 使用SourceTree,可以方便开发人员快速的套用GitFlow开发 ...

  2. 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命令行 ...

  3. [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 ...

  4. git: command not found

    在使用git时,出现“git: command not found”的情况,于是使用yum安装: [root@localhost ~]# yum install -y gitLoaded plugin ...

  5. 警告: 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& ...

  6. Git Command之Code Review

    原文链接 准备 Step 1. Create a team and add a teammate Step 2. Create a repository with some content 应用 Cl ...

  7. git command line 提交代码

    echo "# spring-boot-apollo-demo" >> README.md git init git add README.md git commit ...

  8. 解决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 ...

  9. fuck--Fix git command line spelling errors GitHub

    修复Git输入错误,挺有意思.git命令关键字如果输入错误,会提示最接近的正确关键字,如果提示内容是你想要的,输入'fuck',就能执行了. GitHub源码.源码生成exe,windows上运行. ...

随机推荐

  1. ffmpeg+ffserver搭建流媒体服务器

    http://blog.chinaunix.net/uid-9688646-id-3399113.html ffmpeg和ffserver配合使用可以实现实时的流媒体服务.   一.理解 里边主要有如 ...

  2. 针对安卓java入门:运算符和表达式

    逻辑运算符 &&和&判断是一样的,区别在于过程,&会把整个过程算一遍,&&一旦碰到false就不会往下

  3. iOS:弹出窗控制器:UIPopoverController

    弹出窗控制器:UIPopoverController 截图:   实质:就是将内容控制器包装成popoverController的形式,然后在模态出来,必须给定指向目标(target.frame). ...

  4. 机器人学 —— 机器人视觉(Bundle Adjustment)

    今天完成了机器人视觉的所有课程以及作业,确实是受益匪浅啊! 最后一个话题是Bundle Adjustment. 机器人视觉学中,最顶尖的方法. 1.基于非线性优化的相机位姿估计 之前已经在拟合一篇中, ...

  5. openfire插件开发入门1

    .案例插件的功能 这个插件很简单,就是在openfire Server启动时,和关闭时,在控制台打印出消息. 3.插件开发的目录结构设计 先来看一下当前openfire在eclipse中的目录结构: ...

  6. HDU 4638 Group 树状数组 + 思路

    实际上就是问这个区间编号连续的段的个数,假如一个编号连续的段有(a+b)个人,我把他们分在同一组能得到的分值为(a+b)^2,而把他们分成人数为a和b的两组的话,得到的分值就是a^2+b^2,显然(a ...

  7. PowerDesigner建立与数据库的连接,以便生成数据库和从数据库生成到PD中。

    第一步,打开PD15,找到[Database],如图所示: 第二步,点击新建按钮,创建一个新的ODBC连接. 第三步,这里选择系统数据源,并选择Oracle 第四步,这里需要注意,服务器需要写的是Or ...

  8. Eclipse 下如何引用另一个项目的资源文件

    为什么要这么做?可参考:Eclipse 下如何引用另一个项目的Java文件 下面直接说下步骤:(项目A 引用 项目B的资源文件) 1.右键 项目A,点击菜单 Properties 2.在弹出的框中,点 ...

  9. 推荐个Java代码质量检测的利器 —— FindBugs

    一.下载 插件的下载地址(sourceforge):FindBugs-Eclipse插件 二.安装 Eclipse插件的安装,就不多说了. 三.使用 1.找一个Project,选中它(也可以针对某个P ...

  10. python下载图片

    import re import  urllib.request   def getHtml(url): page = urllib.request.urlopen(url) html = page. ...