---
title: "git常用用法"
author: "kuanghe"
date: "2017-09-06T10:28:33Z"
tags: []
categories: ["开源软件"]
slug: "git"
draft: false
lastmod: "2017-09-06T10:35:46Z"
id: 2392279
url: "https://kuanghe.iteye.com/blog/2392279"
---

git clone
获取一个url对应的远程Git 仓库,
一般的格式是git clone <.
git pull 拉取仓库文件
git pull origin repo 拉取repo分支文件 
git status
 查询状态
git add
   提交新文件或者修改到缓冲区
    git add file 单个或者多个文件
    git add -u：将文件的修改、文件的删除，添加到暂存区。
    git add .：将文件的修改，文件的新建，添加到暂存区。
    git add -A：将文件的修改，文件的删除，文件的新建，添加到暂存区。

第一次提交需要配置本地的
git config –global user.email “邮箱地址”
git config –global user.name “名称”
git commit -m ‘commit message’  提交的信息说明
git push origin  分支名称 列 master 提交

更新代码
git pull origin  branch（分支名称）
git pull 更新代码
git branch new branch //要创建一个新的分支

查看是否创建成功git branch
git checkout new branch //切换到新的分支
切换后可使用 git branch 确认是否切换成功。提交改动到新的分支
git add .
git commit –a
查看提交状态，如果成功 返回要合并提交的分支
git checkout master //切换到主分支
将新分支合并到当前分支
git merge new branch
查看冲突
git diff
问题解决 提交代码
git push origin 分支名称

删除分支
 git branch -d repo(分支名称) 删除本地repo分支