Git学习
0X0:前言
git其实很早就有所接触,但是之前好的教程也少,没学明白,最后找了个图形化界面的先用着了,然后中间有一段时间也没怎么coding,所以也就没了动静,现在又重新拾起,开始coding,所以就从git开始吧!
1X0:全局配置
我觉得这是必要的。
设置commit的默认编辑器:修改 .git/config 中的core中添加editor=vim 或者使用全局设置命令 git config --global core.editor vim
设置提交的身份信息.
git config --global user.name jeb
git config --global user.email "xxx@xxx.com"
添加ssh公匙
ssh-keygen -t rsa -C "xxx@xxx.com"
1X1:基本操作
git init
#初始化仓库
git add <filename>
#将一个文件添加至strage
git add .
git commit -m "xxx"
#将strage中的修改提交到HEAD中
git commit -am "xxx"
git status
git diff
git diff HEAD -- xxxx
git diff HEAD^
git log <--oneline/--decorate/--graph>
git reset HEAD -- xxxx
#版本的恢复
git reset --hard HEAD^|commit_id
git rm -f xxx
git rm --cache xxx
#将strage中最近的cache删除
git reflog
git branch <-D branch_name> <-d branch_name>
git checkout -- xxx
git checkout <-b branch_name>
git merge <--no-ff> <-m "xxx"> branch_name
#合并分支
git stash <list|apply|<stash{0}>|drop|pop|>
#暂存工作
git tag <-a tag_name> <-m tag_commit> <-d tag_name>
#设置tag
git tag show tag_name commit_id
git remote add origin git@github:xxx.xxx
#关联远程仓库
git push -u origin master
#推送本地的master到远程
git push origin tag_name | --tags
git pull branch
#同步远程仓库
use .gitignore to ignore some files #使用.gitignore编辑忽略文件的规则
git check-ignore -v xxx.xxx