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. ISA2006 下建立VPN连接时出现“错误800”时的解决办法

    [转载]http://social.microsoft.com/Forums/zh-CN/9cfa0c06-0f46-44cb-9e8f-8eba1c3821ba/vpn-vpn800 重启Routi ...

  2. virtualbox安装ubuntu出现“The system is running in low-graphics mode”

    cd /etc/X11 sudo mv xorg.conf.failsafe xorg.conf sudo reboot 即可.

  3. StringToInt

    public class Stringtoint {    public static void stringtoint(String s){        //判断字符串是否为null和是否为空   ...

  4. 分享使用method swizzling的经历

    原文:http://www.cnblogs.com/lujianwenance/p/5800232.html   这是一个很蛋疼的过程,先说一下需求,列表页预加载更多(60%).当我看到这个需求的时候 ...

  5. objective-c ios webkit 本地存储local-storage

    我有一个Cocoa / Objective-C的应用程序,它嵌入了一个WebKit的web视图.我需要打开的数据库支持和本地存储.我知道这是可以做到-我有它在Safari中工作-但我无法找到如何设置这 ...

  6. VBA 打印设置相关属性及方法

    打印设置说明,以下均为默认值. With ActiveSheet.PageSetup .PrintTitleRows = "" '工作表打印标题:顶端标题行(R) .PrintTi ...

  7. (转)UIColor 的使用

    os开发-UIColor的使用. 在ios开发中,经常遇到对UIColor的相关操作. 比如这样 self.backgroundColor = [UIColorredColor]; 这里的redCol ...

  8. div 被Object盖住的。解决办法

    今天遇到一个比较头疼的问题,就是在一个标签上右键,弹出的菜单div被标签内的Office控件Object挡住了下半部分,始终无法显示.查了好多解决方案,最终都不能解决问题,几乎都要放弃了.中午吃饭的时 ...

  9. nginx重新加载配置

    1.kill -HUP `cat /usr/local/nginx/logs/nginx.pid` 2./usr/local/nginx/sbin/nginx -s reload

  10. ios8.1.2耗电情况严重的解决方法

    打开cydia,搜索ifile(威锋源,版本2.1.0-1).打开ifile,进入路径/Applications.里面有许多程序文件,选择适当的进行禁用(ifile可以禁用程序的活动而不完全删除它,这 ...