- Workspace:工作区
- Index / Stage:暂存区
- Repository:仓库区(或本地仓库)
- Remote:远程仓库
显示当前的Git配置
git config --list
#编辑Git配置文件
git config -e [--global]
#设置提交代码时的用户信息
git config [--global] user.name "[name]"
git config [--global] user.email "[email address]"
#分支在本地拉取一个远端的serverfix
git checkout -b serverfix origin/serverfix
#merge 本地的localfix分支,不使用fast-forward方式合并,保存分支的commit历史
git merge --no-ff localfix (如warning)
#查看当前的本地分支与远程分支的关联关系
git branch -vv
#将本地新建分支push到自己的本地远程origin上,因为只在本地创建了一个新的分支,远程 origin上还没有该分支
git push origin add_orderdesc
#把本地分支与远程origin的分支进行关联处理(通过 --set-upstream-to 命令)
git branch --set-upstream-to=origin/add_orderdesc
#查看本地分支
git branch
#查看所有分支
git branch -a
#查看远端分支
git branch - r
#push本地分支代码到远端服务器,如果远端服务器没有该分支,将会自动创建
git push origin [远端分支名]
#Git origin master 与 origi你master 的区别: https://blog.twofei.com/695/
origin master is the branch master on the remote repository named origin.
origin/master is your local copy of origin master.
#显示所有标签
git tag
#添加新标签
git tag -a v1.4 -m ‘my version 1.4‘
#推送标签到远端
git push origin [branch] [tagname]
#版本回退
git reset --hard commitNum
git stash save "message"
git stash drop stash@{x}
git stash clear (慎用,会清空没保存的操作)
git stash list
git stash apply
记录每一次命令,用于版本跳转到末端
git reflog
原文:https://www.cnblogs.com/nanchen/p/9528778.html