Git的常用指令

时间:2021-07-25
本文章向大家介绍Git的常用指令,主要包括Git的常用指令使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

//拉取远程仓库代码
git pull

// 提交代码到暂存区
git add .

// 提交到本地仓库
git commit -m '提示信息'

// 提交到仓库
git push

// 检查提交的状态
git status

// 创建本地分支
git branch 分支名

//切换本地分支
git checkout 分支名

// 一次性提交到本地仓库
git commit -am '提示信息'

// 查看远程各分支的最新提交
git branch -r -v

// 删除本地分支
git branch -d 分支名

// 删除远程分支
git branch -r -d origin/分支名

// 查看远程分支
git branch -r

// 合并分支
git merge 你要合并的本地分支名

// 可以查看提交过的日志
git log

// 可以查看记录每一次的命令
git reflog 

// 回退到上一个提交的版本 回退10个可以用
git reset --hard HEAD^ git reset --hard HEAD~10

// 可以git reflog 和 git reset 配合使用来回退git版本

// 以已有的远程分支为源创建新的远程分支

// #创建分支
git checkout -b 分支名 origin/已有的远程分支;

// #提交分支到远程仓库
git push --set-upstream origin 分支名;


// #例如将已有的master为源创建远程分支master_branch
git checkout -b master_branch origin/master;
git push --set-upstream origin master_branch;

// 创建空的远程分支

// #创建分支
git checkout -b 分支名;

// #提交分支到远程仓库
git push --set-upstream origin 分支名;

// #例如创建远程分支master_branch
git checkout -b master_branch;
git push --set-upstream origin master_branch;

原文地址:https://www.cnblogs.com/ark-butterfly/p/15058529.html