Git的安装和使用
整理不易,不喜勿喷。谢谢
SpringBoot — 整合Ldap.
SpringBoot — 整合Spring Data JPA.
SpringBoot — 整合Elasticsearch.
SpringBoot — 整合spring-data-jpa和spring-data-elasticsearch.
SpringBoot — 整合thymeleaf.
SpringBoot — 注入第三方jar包.
SpringBoot — 整合Redis.
Springboot — 整合slf4j打印日志.
Springboot — 整合定时任务,自动执行方法.
Springboot — 配置多数据源,使用JdbcTemplate以及NamedParameterJdbcTemplate.
Sprignboot — 详解pom.xml中build和profile.
SpringBoot — 监控.
SpringBoot — 缓存Cache/Redis.
SpringBoot与Zookeeper.
Git的使用.
1.Install
官网链接:https://git-scm.com/download/win.
一直Next就好了
2.使用
2.1进入
检测安装成功,任意窗口或桌面都可以右键,出现下面两个选项,点击Git Bash Here,进入黑窗口
git config --global user.name "xxxx"
git config --global user.email "xxxxx@163.com"
git config --global user.email "x'x'x'x@x'x'x'xW.COM"
2.2创建仓库
cd D: cd 随便进入一个磁盘
mkdir testgit 创建文件夹
cd testgit 切换到这个文件夹
pwd 显示路径
git init 把这个目录变成git可以管理的仓库
2.3创建完仓库,就可以提交代码
1.在.git目录下创建文件
git add abc.txt
2.git commit -m "abc.txt"
3.查看状态
git status
2.4工作区和暂存区
使用 git add 把文件添加进去,实际上就是把文件添加到暂存区。
使用git commit提交更改,实际上就是把暂存区的所有内容提交到当前分支上。
git checkout --abc.txt 意思就是,把readme.txt文件在工作区做的修改全部撤销,这里有2种情况,如下:
abce.txt自动修改后,还没有放到暂存区,使用 撤销修改就回到和版本库一模一样的状态。
另外一种是readme.txt已经放入暂存区了,接着又作了修改,撤销修改就回到添加暂存区后的状态。
2.5ssh连接
1.在Windeos C盘用户下查找 , 有没有.ssh ,
2.如果没有:
$ ssh-keygen -t rsa -C "your_email@example.com"
直接回车 =>使用默认文件名(推荐),那么就会生成 id_rsa 和 id_rsa.pub 两个秘钥文件。
3.然后输入两次密码 (push文件的时候要输入的密码,而不是github管理者的密码)
可以不写,直接两次回车
4.提示:Your identification has been saved in /c/Users/you/.ssh/id_rsa.
表示ssh创建成功
2.6连接Github
1.用户名下面有个下拉框,选择下拉框
2.点击左侧ssh keys
3.add ssh key
4.复制id_rsa.pub内容到key
$ clip < ~/.ssh/id_rsa.pub 复制内容,使用git语法
2.7远程仓库切换
正常情况:加入连接github
1.git remote add origin https://......
git remote add origin http://xxxxxxxx
2.Git push -u origin master
如果修改远程仓库:
1.git remote rm origin
2.git remote add origin https://github.com/zhaonan0212/Spring_Cloud.git
3.git pull origin master
如果此处报警,fatal: refusing to merge unrelated histories
git pull origin master –-allow-unrelated-histories
4.git push origin master
2.8clone
1.模板 git clone http://邮箱(或用户名):密码@仓库
git clone http://username:password@ip:port/xx/hellowrod.git
2.注意: 邮箱中的 @ 要使用 %40 代替
示例:
邮箱 xxxx@163.com
密码: xxx
仓库: http://git.test.com//demo.html
命令:
git clone http://xxxx%40163.com:xxx@git.test.com/demo.html
2.9报警
1.error: failed to push some refs to ‘https://github.com/zhaonan0212/SoftWare.git’
表示本地与远程的仓库不一致,提示吧远程仓库同步到本地
git pull --rebase origin master
2.电脑修改密码后,git push 时报错 remote: Permission to xxx A. fatal: unable to access
需要修改电脑凭证:
control -> 用户 -> 凭证管理器 -> window 凭证 ->修改对应的git登录密码
3.Idea整合git,提交报错
Auto fetch failed remote error: Invalid username or password.
Idea保留了电脑上一次的密码,需要删除
3.git 学习
3.1提交完了才发现漏掉了几个文件没有添加
$ git commit -m 'initial commit'
$ git add forgotten_file
$ git commit --amend
3.2修改暂存区
# 意外地输入 git add * 暂存了多个文件
$ git add *
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
renamed: LICENSE -> LICENSE.md
modified: readme.txt
#取消暂存
$ git reset HEAD readme.txt
3.3创建分支
3.4删除分支
3.5tag标签
如果忘记打标签,如何补上,先查看log
#删除 tag
$ git tag -d v0.1
Deleted tag 'v0.1' (was 94e0f81)
#推送 tag
$ git push origin v1.0
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
To codechina.csdn.net:xiongjiamu/learning-git.git
* [new tag] v1.0 -> v1.0