git版本 git --version
配置用户名和邮箱( global 设置全局用户,若单项目用户,在其目录下 不使用global 执行)
git config --global user.name “youname”
git config --global user.email “youemai”
查看配置信息
git config --list
查看系统信息
git config --system --list
查看global信息
git config --global --list
查看当前仓库信息
git config --local --list
库操作
创建本地库 git init
关联远程库 git remote add origin https://abc 将远程 https://abc库 以别名origin和本地关联起来
查看远程关联库 git remote -v
仓库操作
创建空仓库 git init
向仓库添加文件到缓冲 git add . / git add filename
提交缓冲文件到仓库 git commit -m “message”
查看当前状态 git status
查看提交log git log
git fetch :将远程主机内容拉到本地,由用户自己决定是否合并到工作分支中
git pull: 将远程主机内容拉到本地并合并 git pull 远程主机(origin) 分支(master)
git push: 将本地版本库推送到远程服务器 git push origin master
分支操作
git checkout -b newbranch :-b 创建并切换分支
git branch newbranch : 创建分支
git checkout newbranch:切换分支
git branch:列出所有分支,并在当前分支前标*
git merge targbranch:在当前分支下合并targbranch
git branch -d branch : 删除分支
新版本git 分支操作
git switch -c dev 创建并切换分支
git switch branch 切换分支
相关问题
若提文件太大或网络不好时,可以修改全局配置
修改缓存为 500M: git config --global http.postBuffer 524288000
配置git的最低速度和最低速度时间
git config --global http.lowSpeedLimit 0
git config --global http.lowSpeedTime 999999(秒)
如果依旧clone失败,则首先浅层clone,然后更新远程库到本地
git clone --depth=1 “https://*.git” “localpath”
git fetch --unshallow