---
title: "git push 命令"
author: "langgufu"
date: "2016-05-09T17:25:06Z"
tags: ["Git", "git push"]
categories: ["开源软件"]
slug: "git-push"
draft: false
lastmod: "2016-05-09T17:32:16Z"
id: 2296901
url: "https://langgufu.iteye.com/blog/2296901"
---

git push 完整命令：git push origin localbranch:remotebranch，在本地分支和远程分支没有关联的情况下，本地分支和远程分支必须有一个、

1.当忽略掉远程分支名字时，只有本地分支名字，意味着远程分支名字等同于本地分支名字，如：git push origin localbranch

 

2.当忽略掉本地分支名字时，只有远程分支名字，意味着删除远程分支，如：git push origin :remotebranch

 

3.当都忽略掉远程分支和本地分支时，如:git push ，则远程分支和本地分支关联了时没有问题，若没有关联则会出错，需要先设置关联，命令如下：git push --set-upstream origin testbranch，设置当前分支和远程分支关联