Author:
nice01qc
Time :
Time :
git常用命令汇总
简单地总结Maven的使用…
git 一些常用命令
# 首次安装配置用户
git config --global user.name "Your Name" # 使用`--global` 表示本机所有git仓库都公用这个
git config --global user.email "email@example.com"
# 常用的一套流程
git init # 初始化仓库
git add . # 提交所有改变了的新的东西添加到暂存区
git commit -m"注释" #提交到本地仓库
git push <-f> 远程仓库 远程仓库分支 # 加上-f 表示强制本地同步到远程仓库
# git push --all origin # 将所有本地分支都推送到远程仓库
# 拉取远程分支,同步合并
git fetch 远程仓库 远程仓库分支:本地分支 # 把远程某分支拉取到本地分支,若没有则会新建一个分支
# git fetch origin matlabshow:matlabshow
# 版本回退
git reset --hard HEAD^^ # 几个^代表往后回退几个版本
git reset --hard commitID # 通过commit的id回退到指定的版本
git reset --hard 分支名 # 回退到具体的分支
git checkout <file> # 回退到第一次git add / git commit 的状态
git reset HEAD <file> # 撤销已经提交到暂存区的修改
# 远程仓库与分支
git remote -v # 查看所有远程仓库
git remote add name url # 添加远程仓库
git remote remove name # 删除远程仓库
git branch -v # 查看本地所有分支
git branch -r # 查看所有远程分支
git branch -a # 查看所有分支
git branch newBranch #新建分支
git branch -d #删除分支
git push origin --delete dev #删除远程dev分支
git push <远程主机名> <本地分支名>:<远程分支名> # 将分支推向远程
git checkout branchName # 切换分支
git remote update origin # 更新分支
# 其他
git statuts # 查看当前git仓库状态
git diff # 查看差异
git log
#公司常用
git checkout -b 本地分支名 origin/远程分支名 #从远程仓库里拉取一条本地不存在的分支,并命名为“本地分支名”
git fetch --all #拉取当前分支所有内容(分支名字为 origin/远程分支名)
git diff 本地分支名 origin/远程分支名 #展示两个分支差别
git merge origin/远程分支名 #本地分支与远程分支合并,如果有歧义,需要修改“本地内容",修改后继续提交
###idea 有相关操作,很方便,可以试着用idea验证上面内容
参考资料
https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000