Git

Git

下载

https://npm.taobao.org/mirrors/git-for-windows/

启动

Git Bash: unix与linux风格的命令行

Git CMD: windows风格的命令行

Git GUI: 图形界面的Git

配置文件

system配置 **Gitetcgitconfig

global配置 C:UsersAdministrator.gitconfig

配置global中的用户名和邮箱

工作区域

working directory: 工作区

stage(index): 暂存区

repository: 仓库区

remote: 远程仓库

项目搭建

git init	初始化

git clone [url]	克隆

文件操作

git status	#获取状态

git add .	#添加所有文件到暂存区

git commit -m "message"	#提交暂存区的内容至本地仓库 -m "信息"

git push	#提交至远程仓库

忽略文件

在目录中建立".gitignore"文件, 规则如下:

注释

*.txt 忽略所有txt格式的文件

!lib.txt 除了lib.txt

/temp 仅忽略除temp目录外的文件

build/ 忽略build/目录下的所有文件

doc/*.txt 忽略doc目录下的txt, 但不包括其子目录下的txt

Gitee

设置本机绑定SSH公钥, 免密码登录

ssh-keygen -t rsa	#生成公钥至C:UsersAdministrator.sshid_rsa.pub

绑定页面

https://gitee.com/profile/sshkeys

分支

git branch	#所有本地分支

git branch -r	#所有远程分支

git branch [branch-name]	#后台新建一个分支

git checkout -b [branch]	#新建并打开分支

git merge [branch]	#合并指定分支到当前分支

git branch -d [branch-name]	#删除分支

git push origin --delete [branch-name]	#删除远程分支
git branch -dr [remote/branch]	#同上
原文地址:https://www.cnblogs.com/pinked/p/12683540.html