标准Git注解
第1行:提交修改内容的摘要
第2行:空行
第3行以后:修改的理由
初始化git
git init

连接git
git remote add l链接别名 git地址链接

克隆git分支
git clone -b 分支名 git链接地址//克隆特定分支
git clone 分支名 git链接地址 //默认克隆master分支
查看本地git分支
git branch -a //查看全部地址分支

删除本地git分支
git branch -d/-D 分支名
查看git状态
git status
切换分支git
git checkout 分支名
gitcheckout -b 分支名 // 新建本地分支并切换到当期分支
保存当前正在敲的工作区git代码----在当前分支上进行暂存工作区代码
git stash
用下面这个代替
推荐给每个stash加一个message,用于记录版本
git stash save "注释"
查看当前正在敲的工作区git代码
git stash list
移除stash
$ git stash list
stash@{0}: WIP on master: 049d078 added the index file
stash@{1}: WIP on master: c264051 Revert "added file_size"
stash@{2}: WIP on master: 21d80a5 added number to log
$ git stash drop stash@{0}
Dropped stash@{0} (364e91f3f268f0900bc3ee613f9f733e82aaed43)
查看指定stash的diff
git stash show 文件名
查看远程连接
git remode -v

删除远程连接
git remote rm github
重置远程连接git
git remte set-url origin URL
删除远程git分支
git push --delete 链接别名 远程分支名

拉取git分支(远程新建分支)
1.
git fetch origin(连接别名) master(分支)
git add.
git commit -m 注释
git push
完成远程新建分支
2.
git branch 分支名
git push origin(链接别名) 分支名

解决冲突
回滚
git reset --hard HEAD^ 回到上一个版本
git reset --hard HEAD~10 回到第10个之前
git reflog 用来记录你的每一次命令
git reset --hard 版本号
已经Git push 上去,回滚
用git revert来撤销已经提交的更改,而git reset用来撤销没有提交的更改
git revert HEAD~3 //丢弃最近的三个commit,把状态恢复到最近的第四个commit,并且提交一个新的commit来记录这次改变
git revert -n master~5..master~2
//丢弃从最近的第五个commit(包含)到第二个(不包含),但是不自动生成commit,这个revert仅仅修改working tree和index。
修改最近上一次commit的注释信息
git commit --amend
查看版本号信息
git shortlog 用户提交哪些组,再次显示简洁的主题行
git reflog
git log
忽略.idea文件夹下文件
git rm -r --cached .idea
删除idea缓存
.gitignore中添加.idea
git pull时出现冲突 放弃本地修改,使远程库内容强制覆盖本地代码
git fetch --all //只是下载代码到本地,不进行合并操作
git reset --hard origin/master //把HEAD指向最新下载的版本
git 设置不用每次都输入 账号密码
执行一下 这个命令:
git config --global credential.helper store
然后,下次再输入一次 账号密码 就可以了。
git merge 出现以下错误

git merge 分支名 --allow-unrelated-histories
git pull 出现以下错误
拒绝合并不相关历史
fatal: refusing to merge unrelated histories
git pull --allow-unrelated-histories
git clone报错

使用Git clone代码失败的解决方法1
使用Git clone代码失败的解决方法2
error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
或者是以下错误
error: RPC failed; curl 18 transfer closed with outstanding read data remaining
fatal: The remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
我们的项目由于时代久远,所以导致整个项目比较复杂庞大。
出现这种错误,就是因为curl的postBuffer默认值太小的原因,重新在终端配置一下这个值就可以了。
因为Git限制了推送数据的大小导致的错误。
解决方法:重新设置通信缓存大小
git config http.postBuffer 524288000
或者
git config --global http.postBuffer 524288000
git config http.sslVerify "false"
出现错误:fatal: not in a git directory
git config --global http.sslVerify false
解决方法:添加--depth 1
git 命令后面加 --depth 1
BUG解决 win10专业版安装完后git bash 出现闪退现象
win10 专业版 git bash 闪退问题终极解决方案
替换以下C:\Windows\System32\drivers\null.sys路径下的文件
链接:https://pan.baidu.com/s/1UtcZizm-iFcVk4OKrnFJVg 密码:1q4d
还在补充中ing......
网友评论