一般常用命令
git init //生成.git目录
git add . //把当前目录里的文件加入到暂存区
git add README //更新README文件
git commit -m ‘上传’ //从暂存区提交到仓库
git remote add origin 远程仓库地址 //添加远程仓库
git branch --set-upstream-to=origin/ master //本地仓库和远程仓库关联,git pull时就会有提示
git status //会有信息显示:Your branch is up-to-date with ‘origin/master’.不过一般远程仓库会和现有仓库合并不了,单纯的git pull会提示fatal: refusing to merge unrelated histories
git pull --rebase origin master //看来以rebase变基的方式可以合并啊
git push //提交到远程仓库
git push -u origin master
大文件
上传大文件报错remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
git lfs install //安装LFS
git lfs track ".a" //".a"是上传的大文件路径
git add .gitattributes //添加,相当于add .
git add 大文件 //添加大文件到本地缓存区
再commit>>push
其他
git config --global core.autocrlf false //关闭自动换行
git config --global core.safecrlf true
git tag # 列出当前仓库的所有标签
git tag -l ‘v0.1.*’ # 搜索符合当前模式的标签
git tag v0.2.1-light # 创建轻量标签
git tag -a v0.2.1 -m ‘0.2.1版本’ # 创建附注标签
git checkout [tagname] # 切换到标签
git show v0.2.1 # 查看标签版本信息
git tag -d v0.2.1 # 删除标签
git tag -a v0.2.1 9fbc3d0 # 补打标签
git push origin v0.1.2 # 将v0.1.2标签提交到git服务器
git push origin --tags # 将本地所有标签一次性提交到git服务器
git tag # 查看当前分支下的标签
变更项目地址
git remote set-url origin git@192.168.6.70:res_dev_group/test.git
git remote -v