[GIT]git创建及其使用心得

本文章涉及到了git的创建和基本操作,适合初学者使用

查看本地分支 git branch
切换分支 git checkout ‘name’
删除本地分支 git branch -d ‘name’
创建新分支 并切换到改分支 git checkout -b ‘name’
查看线上分支 git branch -r
克隆并创建分支 git checkout -b ‘newname’ master
本地分支提交到远程 git push origin ‘name’
撤销本地的修改 git checkout — 文件名
撤销本次提交的代码 git reset –hard HEAD~1

查看所有版本 git reflog
回到某个版本 git reset –hard XXXXX

分支提交 git push origin resblock 最后为分支名
分支下载 git pull origin resblock ‘resblock 为分支名’
删除远程分支 git push origin : 自己分支名 删除远程分支
合分支 git merge deyou(分支名) –no-ff git push origin master
rebase
在自己分支上进行 git rebase master 处理冲突后进行 git rebase –continue 放弃处理 git rebase -abort
git checkout –our

//暂存修改
git stash
git stash pop

//修改配置,快捷键
vim ~/.gitconfig
[alias]
last = log >—lg = log –color –graph –pretty=format:’%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset’ –abbrev-commit
lg = log –color –graph –pretty=format:’%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset’ –abbrev-commit
ci = commit
br = branch
co = checkout
df = diff
st = status

创建自己的git方法
1, 下载git 找到相应目录,git init
2, 根目录下去寻找.ssh目录。寻找SSH KEY

$ ssh-keygen -t rsa -C &quot;youremail@example.com&quot;

3, 登录github 打开account setting Add SSH KEY
4, Create
a new repo
5, 按照提示
//git init
//git add README.md
//git commit -m “first commit”
git remote add origin
git@github.com:wangchunwei/shulan.git
git push -u origin master

发表评论

电子邮件地址不会被公开。 必填项已用*标注


*