博客
关于我
git学习笔记:切换本地分支master到main,并推送
阅读量:802 次
发布时间:2019-03-25

本文共 815 字,大约阅读时间需要 2 分钟。

Git 分支操作指南

1. 创建并切换到新分支

在需要进行开发之前,我们需要为新功能创建自己的分支。假设你正在从`master` 分支切换过去,可以使用以下命令:

```bashgit checkout -b main```这样做会自动创建并切换到名为`main`的新分支。

2. 检查当前 git 分支

为了验证当前所在的分支,执行以下命令:

```bashgit branch```这将显示目前所在的工作区中所有存在的分支。

3. 将主分支合并到当前工作分支

在完成一些功能开发后,我们需要将`master`分支合并到当前的工作分支`main`:

```bashgit merge master```这样操作将会将`master`分支的所有提交历史合并到当前的`main`分支中。

4. 从原仓库拉取最新代码

有时候 you 可能会遇到网络问题,导致拉取代码失败。可以使用以下命令尝试拉取最新版本:

```bashgit pull origin main --allow-unrelated-histories````--allow-unrelated-histories`选项允许不相关的历史提交被拉取,这可以帮助解决网络问题。

5. 将修改推送到远程仓库

在确认所有修改已经完成后,可以将改动推送到远程仓库:

```bashgit push origin main```如果推送过程中遇到错误,可以多次尝试执行此命令,因为网络问题可能会导致它暂时无法完成。

6. 删除本地和远程的旧分支

当不再需要`master`分支时,可以确保删除它以保持仓库整洁。

先从本地仓库删除:

```bashgit branch -D master```

然后从远程仓库删除(建议联网时使用以下命令):

```bashgit push origin --delete master```这样可以确保`master`分支不再影响到你的工作流程。

转载地址:http://ixnyk.baihongyu.com/

你可能感兴趣的文章
TCP基本入门-简单认识一下什么是TCP
查看>>
tableviewcell 中使用autolayout自适应高度
查看>>
Orcale表被锁
查看>>
svn访问报错500
查看>>
org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned
查看>>
org.apache.ibatis.type.TypeException: Could not resolve type alias 'xxxx'异常
查看>>
org.apache.poi.hssf.util.Region
查看>>
org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions;
查看>>
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /
查看>>
org.hibernate.HibernateException: Unable to get the default Bean Validation factory
查看>>
org.hibernate.ObjectNotFoundException: No row with the given identifier exists:
查看>>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
查看>>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
查看>>
org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded
查看>>
org.tinygroup.serviceprocessor-服务处理器
查看>>
org/eclipse/jetty/server/Connector : Unsupported major.minor version 52.0
查看>>
org/hibernate/validator/internal/engine
查看>>
SQL-36 创建一个actor_name表,将actor表中的所有first_name以及last_name导入改表。
查看>>
ORM sqlachemy学习
查看>>
Ormlite数据库
查看>>