git 常用命令的总结

1、 git 查看分支

git branch (星号代表当前的分支)

2、 创建一个本地分支

git checkout -b 分支名称

3、 将本地新建分支提交到远程

git push origin 分支名称:分支名称

4、 删除远程分支

git push origin  :分支名称

5、 删除本地分支

git branch -d 分支名称
// 强制删除分支
git branch -D 分支名称

6、 切换分支

git checkout 分支名称

7、 如果本地有多个分支,指定本地分支追踪远程的哪个分支

// 设置本地分支 local_branch 追踪远程分支 origin/<branch>
git branch --set-upstream-to=origin/<branch> local_branch

// 本地 master 追踪远程 master
git branch --set-upstream-to=origin/master master

8、 更新本地仓库

git pull

9、 查看本地修改

git status

10、 更新远程分支信息到本地

git fetch

11、 将远程项目下载到本地,默认 clone 的是这个仓库的 master 分支。

//1. 在本地创建空的项目目录, /temp/pro
//2. 初始化本地目录
git init

// 复制远程项目git地址, https://github.com/pagehelper/Mybatis-PageHelper.git
//3. 使用命令下载到本地
git clone https://github.com/pagehelper/Mybatis-PageHelper.git

12、 查看远程分支

git branch -r

13、 拉取远程分支代码并切换到该分支

git checkout -b origin/develop

 14、查看远程仓库地址

git remote -v

15、修改本地的远程仓库地址

// 删除远程仓库地址
git remote rm origin
// 添加新的远程仓库地址
git remote add origin 你的新远程仓库地址

参考文献:

https://blog.csdn.net/weixin_34239592/article/details/91423705

https://blog.csdn.net/bjzhaoxiao/article/details/95595758

 https://git-scm.com/book/zh/v1/Git-%E5%9F%BA%E7%A1%80-%E8%BF%9C%E7%A8%8B%E4%BB%93%E5%BA%93%E7%9A%84%E4%BD%BF%E7%94%A8

https://blog.csdn.net/m0_37034294/article/details/79986198

原文地址:https://www.cnblogs.com/zhaopengcheng/p/11754353.html