git推送本地分支到远端

当前处于master分支,尝试用了git push origin

warning:
push.default is unset; its implicit value is changing in Git 2.0 from 'matching' to 'simple'.
To squelch this message and maintain the current behavior after the default changes, use:

git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

git config --global push.default simple

When push.default is set to 'matching', git will push local branches to the remote branches that already exist with the same name.

In Git 2.0, Git will default to the more conservative 'simple' behavior,
which only pushes the current branch to the corresponding remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode 'current' instead of 'simple' if you sometimes use older versions of Git)

push的时候,指定远端名称,然后本地分支名称:远端分支名称

$ git push origin Test:master

将本地的Test分支推送到远端的master分支

通过命令删除远端分支

之前推送本地的代码到远端的时候,远端的分支名字写错了,导致远端产生了一个新的分支

之前用的git push -f origin Test:mater

$ git push origin :mater
Username for 'https://github.com': chucklu
Password for 'https://chucklu@github.com':
To https://github.com/chucklu/WCFTest.git
- [deleted] mater

git push origin :mater

推送一个空白分支到mater上,相当于删除mater分支

这次失误了,推送的时候,多了一个空格。然后直接就推送了一个新的同名分支到远端,并且删除了master分支

Administrator@LuJunTao MINGW64 /d/SourceCode/GameSourceCode/Hearthstone-Deck-Tracker (master)
$ git push chucklu chucklu_master :master
Username for 'https://github.com': chucklu
Password for 'https://chucklu@github.com':
Counting objects: 8, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 765 bytes | 0 bytes/s, done.
Total 8 (delta 6), reused 0 (delta 0)
To https://github.com/chucklu/Hearthstone-Deck-Tracker.git
- [deleted] master
* [new branch] chucklu_master -> chucklu_master

补救措施

Administrator@LuJunTao MINGW64 /d/SourceCode/GameSourceCode/Hearthstone-Deck-Tracker (master)
$ git push chucklu chucklu_master:master
Username for 'https://github.com': chucklu
Password for 'https://chucklu@github.com':
Total 0 (delta 0), reused 0 (delta 0)
To https://github.com/chucklu/Hearthstone-Deck-Tracker.git
* [new branch] chucklu_master -> master

Administrator@LuJunTao MINGW64 /d/SourceCode/GameSourceCode/Hearthstone-Deck-Tracker (master)
$ git push chucklu :chucklu_master
Username for 'https://github.com': chucklu
Password for 'https://chucklu@github.com':
To https://github.com/chucklu/Hearthstone-Deck-Tracker.git
- [deleted] chucklu_master

推送的时候分支和远端分支如果名字一样,且repository有多个remote,那么git push remoteName

如果本地分支的名字和远端分支名字不一样,就需要显式指定了

当前处于要推送的分支上

git push remoteName HEAD:RemoteBranchName

当前不处于要推送的分支上

git push remoteName localBranchName:RemoteBranchName

git推送本地分支到远端 以及删除远端分支的 命令的更多相关文章

  1. git 推送本地项目到远程库

    git 推送本地项目到远程库 1@DESKTOP-3H9092J MINGW64 /e/mozq/00store/01/SmartCard_MS $ git init Initialized empt ...

  2. git推送本地分支到远程分支

    场景 有时候我们开发需要开一个分支,这样可以有效的并行开发. 开分支有两种方式: 一种是在远程开好分支,本地直接拉下来; 一种是本地开好分支,推送到远程. 远程先开好分支然后拉到本地 git chec ...

  3. git推送本地仓库到github

    总结一下,方便后人,也方便自己查阅.直接写步骤 一.本地创建一个文件夹,在里面写项目的文件(* .php/*.js.....). git本地操作: 1 .  cd  /path/to/project  ...

  4. Git - Git推送本地分支到远程分支报错(! [rejected] non-fast-forward)的解决办法

    一般都是冲突造成的,解决方案执行如下命令(dev为分支名称): git fetch origin dev  #获取远程 dev 分支的修改 git merge origin dev       #合并 ...

  5. git推送本地分支到远程仓库并在远程仓库创建新分支

    $ git push <远程主机名> <本地分支名>:<远程分支名> git push master test:test #master 为设置的远程仓库别名,第一 ...

  6. git 分支管理 推送本地分支到远程分支等

    1.创建本地分支 local_branch git branch local_branch 2.创建本地分支local_branch 并切换到local_branch分支 git checkout - ...

  7. Git 推送分支

    1.推送本地分支到远程: git push origin master  推送本地分支 master 到 远程的 origin 上面   git push origin test 将本地分支test推 ...

  8. Git for Windows之推送本地版本库到远程仓库

    Git for Windows之基础环境搭建与基础操作中介绍了Git基本环境的构建与基本的操作.生成了一个本地git版本库,本文将介绍如何将这个版本库推送到远程仓库(码云,github也可以). 1. ...

  9. git推送tag到远端服务器

    git推送tag到远端服务器 默认情况下,git push并不会把tag标签传送到远端服务器上,只有通过显式命令才能分享标签到远端仓库.1.push单个tag,命令格式为:git push origi ...

随机推荐

  1. 将vs2012的项目转化成VS2010

    vs2012生成的项目,如何在只装有VS2010的电脑上打开, 步骤: 1.打开一个记事本,将你的Vs2012生成的项目解决方案文件(.sln文件)文件拖到记事本中 2.修改前两行  Microsof ...

  2. 关于ContentProvider的批量操作

    今天看公司代码,发现在批量插入通话记录和联系人的时候,用了一个 ArrayList<ContentProviderOperation> ops = new ArrayList<Con ...

  3. hdoj1874 (优先队列+Dijkstra)

    hdoj1874 分析: 一看题目, 就是求最短路, 这道题用的是Dijkstra+优先队列.先说一下Dijkstra算法:每次扩展一个距离最短的节点, 更新与其相邻点的距离. 当所有边权都为正时, ...

  4. LINQ里的Distinct()

    IQueryable 继承自IEnumerable 先举例: #region linq to object List<People> peopleList = new List<Pe ...

  5. SQL 查找存储过程及视图与自带函数

    查找所有所有存储过程的名称及信息select * from sysobjectswhere type='P' 查看存储过程定义语句sp_helptext [存储过程名] 查看所有视图及信息select ...

  6. fastjson的坑 com.alibaba.fastjson.JSONObject cannot be cast to xxx

    解析json对象时,使用了new TypeReference()对象 fastjson会对解析的对象类型进行缓存   new TypeReference<ResultData>(){}   ...

  7. 【转】oracle Sequence

    http://blog.csdn.net/zhoufoxcn/article/details/1762351 在oracle中sequence就是序号,每次取的时候它会自动增加.sequence与表没 ...

  8. 方便mac os 10.9系统中phpstorm配置php运行环境

    自己安装php,不用mac安装,这样就有php开发环境了. 安装很简单,直接运行一个命令, 需要几分钟,请慢慢等待. curl -s http://php-osx.liip.ch/install.sh ...

  9. ASP.NET 共用类库

    using System; using System.Collections.Generic; using System.Text; using System.Web; using System.We ...

  10. windows appfabric samples

    http://www.microsoft.com/en-us/download/details.aspx?id=19603 http://msdn.microsoft.com/zh-cn/librar ...