git命令

clone  克隆远程仓库

init      初始化仓库

remote 连接远程仓库

pull      从远程仓库下拉获取新数据

push    将本地仓库新增或修改文件上传到远程仓库

add    添加文件或者修改文件,commit以及push之前使用

log      当前仓库提交过的日志信息

status  当前仓库版本状态

commit 提交到当前仓库中

branch 分支命令,相关增删查操作

checkout 使用远程仓库最后一个版本完全覆盖当前仓库内容/选择分支branch

diff      对比版本内容

merge  合并版本内容

git add . //添加

git commit -m 'xxxx' //提交

git push origin master //提交服务器

git pull //下载服务器最新版本

git pull <远程库名> <远程分支名>:<本地分支名> git pull origin online:online

git branch # 列出所有本地分支

git branch -r # 列出所有远程分支

git branch -a # 列出所有本地分支和远程分支

git branch [branch-name] # 新建一个分支,但依然停留在当前分支

git checkout -b [branch] # 新建一个分支,并切换到该分支

git branch [branch] [commit] # 新建一个分支,指向指定commit

git branch --track [branch] [remote-branch] #新建一个分支,与指定的远程分支建立追踪关系

git checkout [branch-name] # 切换到指定分支,并更新工作区

git checkout - # 切换到上一个分支

git branch --set-upstream [branch] [remote-branch] # 建立追踪关系,在现有分支与指定的远程分支之间

git merge [branch] # 合并指定分支到当前分支

git cherry-pick [commit] # 选择一个commit,合并进当前分支

git branch -d [branch-name] # 删除分支

git push origin --delete [branch-name] # 删除远程分支

git push origin  [branch-name] //提交远程分支

git branch -dr [remote/branch]

解决文件冲突

git stash #先将本地修改存储起来 

git stash list #查看保存的信息

git pull

git stash pop stash@{0} #还原暂存的内容

HEAD指向的版本就是当前版本,因此,Git允许我们在版本的历史之间穿梭,使用命令

git reset --hard commit_id。

穿梭前,用

git log可以查看提交历史,以便确定要回退到哪个版本。

要重返未来,用

git reflog查看命令历史,以便确定要回到未来的哪个版本。

查看分支:git branch

创建分支:git branch

切换分支:git checkout

创建+切换分支:git checkout -b

合并某分支到当前分支:git merge

删除分支:git branch -d

解决git 在pull或者合并分支的时候有时会遇到这个界面

按键盘左上角"Esc"

输入":wq",注意是冒号+wq,按回车键即可

GIT提交备注规范

feat :新功能

fix :修复bug 

doc : 文档改变

style : 代码格式改变

refactor :某个已有功能重构

perf :性能优化

test :增加测试

build :改变了build工具 如 grunt换成了 npm

revert: 撤销上一次的 commit

查看所有配置 git config --list 

修改GIT用户名  git config [--global] user.name "[name]"

你可能感兴趣的:(git命令)