安装git:

版本管理系统的基本组件http://git-scm.com/download/win注意区分32-bit与64-bit版本

 

安装之后会开始菜单里面有以下文件:

默认安装之后会出现以下文件夹:

 

启动 git bash

 

显示查看当前配置(git bash中输入以下命令; 小写的字母L)

git config -l

 

显示查看系统的配置(git bash中输入以下命令)

git config --system --list

 

显示查看用户自己配置的信息(git bash中输入以下命令)

git config --global --list

 

git安装目录下

git\etc\gitconfig 是系统的配置文件

 

用户目录下

.gitconfig 是用户自己的配置文件

 

user.name 必须配置

user.email 必须配置 (git bash中输入以下命令)

$ git config --global user.name "Your Name"

$ git config --global user.email "email@example.com"

基本理论   

 

工作目录 Workspace,本地存放项目代码的地方

暂存区 Stage(index),本地临时存放改动

本地git仓库(History)

远程git仓库(Remote Directory)

 

git 工作流程示意图(下图1):

 图1

 

 

 

 

 

本地初始化仓库(git bash中输入以下命令)

git init

 

克隆远程仓库 (git bash中输入以下命令)

git clone Remote-URL

 

 

文件操作

文件的四种状态:

Untracked: 未跟踪;

Unmodify:文件未修改

Modified:文件已经修改

Staged:暂存状态

 

git status   # (git bash中输入命令)查看状态

git add .   # (git bash中输入命令) 添加全部文件到暂存区

git commit -m "messages"   # (git bash中输入命令) 提交暂存区到本地库

 

忽略文件

.gitignore

 部分文件不需要追踪(比如.idea中的文件不需要提交,不需要跟踪版本)

 *.txt   # 不需要提交

!lib.txt  # 不被忽略

/temp  # 之前的全部

build/  # 之后的全部

doc/*.txt

 

免密码登录gitee

# 进入 C:\Users\Administrator\.ssh 目录

# 生成公钥

ssh-keygen -t rsa

说明:https://gitee.com/help/articles/4181#article-header0

注册和登录gitee -- 设置 -- ssh

新建仓库

 

idea中使用git

idea 建立项目,git 拷贝已经clone的仓库的文件即可。

 

 

 

 

分支(新建,切换,合并)

## 查看所有分支

git branch

## 查看远程的分支

git branch -r

## 新建分支

git branch dev

## 切换分支; checkout的分支变为当前分支

git checkout -b [branch]

## 合并指定分支到当前分支

git merge [branch]

 

 

REF

https://www.bilibili.com/video/BV1FE411P7B3

 

查看原文