git commant
- 查看配置
git config --list
- git设置用户信息
git config --global user.name "lee-fx"
git config --global user.email 1325132
- 创建仓库
git init
git clone githubRemoteUrl localName
- 忽略提交文件格式
创建 .gitignore 文件 通过正则过滤掉文件
- 提交修改
git status
git status -s
git show
git commit -m "msg"
git log
git commit -amend -m "msg"
- 检出分支
git checkout origin/test -b mytest
- diff比较不同
git diff fileName
git branch
git branch -a
- git回退
git checkout fileName
git chectout - fileName
git reset -hard HEAD~num
- 操作历史
git reflog
git rm fileName
git log --pretty=oneline
- 远程仓库(remote)
ssh-keygen -t rsa -C "mail name"
git remote add localRemoteName remoteUrl
git remote rm localRemoteName
git remote rename name1 name2
git pusha -u origin master
git pull -rebase
- 打标签
git tag
git tag -a v1.0.0 -m ‘my version 1.0.0’
git show v1.0.0
git tag v1.0.0-lfx
git show v1.0.0-lfx
- 提交代码示例
1 首先使用 git add 把工作区的修改提交到暂存区
git add test.php
2 执行 git commit 把暂存区的修改生成 commit 提交到当前分支中
git commit -m "test patch"
3 使用 git push 把本地仓库的修改分支提交到远程仓库。
git push origin HEAD:master