1 # GitLab(局域网)
2 # GitHub(外网)
3 # Gitee码云(外网-国内)
4 # 常用命令
5 git config --global user.name Chad # 设置用户名
6 git config --global user.email chad@cargoarmor.com # 设置邮箱
7 git init # 初始化本地库
8 git status # 查看本地库状态
9 git add hello.txt # 将文件添加到暂存区
10 git rm --cached hello.txt # 将文件从暂存区移除
11 git commit -m "First commit" hello.txt # 提交本地库,并附加了提交说明
12 git reflog # 查看版本信息
13 git log # 查看版本迭代记录
14 git reset --hard 5770506 # 回到旧版本
15 git branch -v # 查看分支
16 git branch hot-fix # 创建分支,hot-fix是分支名
17 git checkout hot-fix # 切换分支
18 git merge hot-fix # 将当前分支与hot-fix进行合并
19
20 git remote -v # 查看本地库别名
21 git remote add git-demo https://github.com/tetsttets/git-demo.git # 这样就创建了git-demo别名
22 git remote remove git-demo # 移除本地库别名
23 git push git-demo master # 将master分支推送到git-demo远程库中去
24 git pull git-demo master # 拉取远程库git-demo的master分支代码
25 git clone https://github.com/tetsttets/git-demo.git # 克隆远程库
26
27
28 ssh-keygen -t rsa -C chad@cargoarmor.com # 生成免密登录密钥 -C 描述。免密登录就是将公钥配置到github的ssh中。
29
30
31 # 配置忽略文件(与项目无关的文件不上传):
32 # 一、新建git.ignore,并配置忽略的文件类型
33 *.class
34 *.log
35 *.ctxt
36 # 这是忽略目录
37 .mtj.tmp/
38 *.jar
39 *.war
40 *.nar
41 *.car
42 *.zip
43 *.tar.gz
44 *.rar
45 # 二、然后在.gitconfig配置文件中配置
46 [core]
47 cxcludesfile=/home/pc1/git.ignore
48
49 # gitlab
50 # 官网:https://about.gitlab.com/
51 # 安装:https://about.gitlab.cn/install
52 # 你也可以通过docker安装:https://docs.gitlab.cn/jh/install/docker.html