GIT个人使用总结
Git流程图
workspace:本地文件
staging area:暂存区
local repository:本地仓库
remote repository:远程仓库
IDEA中文件颜色
绿色:已经加入控制暂未提交
红色:未加入版本控制
蓝色:已加入,已提交,有改动
黑色:已加入,已提交,无改动
灰色:版本控制已忽略文件
Git基本命令
1、配置Git
配置信息
git config --list
设置提交代码的用户信息
git config --global user.name "name"
git config --global user.mail "email"
2、查看仓库当前状态
git status
3、新建本地仓库
git init [project-name]
4、远程操作(remote)
显示当前的远程仓库信息(-v 查看远程地址)
git remote [-v]
添加远程仓库关联(shortname:远程主机别名,默认为origin)
git remote add [shortname] [git地址]
修改关联仓库的名字(本地别名修改)
git remote rename [old] [new]
删除关联仓库(本地删除,远程仍是存在)
git remote rm [name]
问题:通过本地自建仓库再关联远程项目会出现(fatal: refusing to merge unrelated histories)
解决方案1:git pull origin master --allow-unrelated-histories
解决方案2:先clone项目,再将本地文件放入提交