---
title: "Git常用命令与配置"
author: "joesay"
date: "2012-12-22T12:38:39Z"
tags: []
categories: ["开源软件"]
slug: "git"
draft: false
lastmod: "2012-12-27T10:38:58Z"
id: 1752328
url: "https://joesay.iteye.com/blog/1752328"
---

**git服务器搭建相关命令**

 

参考网址1：[http://weizhifeng.net/build-git-server-with-gitosis.html](http://weizhifeng.net/build-git-server-with-gitosis.html)

参考网址2：[http://joesay.iteye.com/blog/1541911](/blog/1541911)

 

 

**git仓库设置相关命令**

 

参考网址：[https://help.github.com/articles/changing-a-remote-s-url](https://help.github.com/articles/changing-a-remote-s-url)

 

 

```
git remote set-url origin git@git-server-ip:xxx.git
```

 

 

**git分支管理相关命令**

 

参考网址：[http://www.open-open.com/lib/view/open1328069889514.html](http://www.open-open.com/lib/view/open1328069889514.html)

 

- 列出所有分支
  
  - git branch

<!--THE END-->

- 建立本地Branch： 
  
  - git branch weibo-marketing-platform-sharding

<!--THE END-->

- 提交本地Branch到远程服务器：
  
  - git push origin weibo-marketing-platform-sharding:weibo-marketing-platform-sharding

<!--THE END-->

- 切换branch：
  
  - git checkout weibo-marketing-platform-sharding

<!--THE END-->

- 远程机器同步branch：
  
  - git pull
  - git checkout weibo-marketing-platform-sharding