github上面新建分支

本文详细介绍了如何在GitHub Fork中维护master分支的清洁,包括创建、切换、合并及删除分支的方法,确保代码流线清晰高效。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

In your github fork, you need to keep your master branch clean, by clean I mean without any changes, like that you can create at any time a branch from your master. Each time, that you want to commit a bug or a feature, you need to create a branch for it, which will be a copy of your master branch.

When you do a pull request on a branch, you can continue to work on another branch and make another pull request on this other branch.

Before creating a new branch pull the changes from upstream, your master needs to be up to date.

Create the branch on your local machine and switch in this branch :

$ git checkout -b [name_of_your_new_branch]

Push the branch on github :

$ git push origin [name_of_your_new_branch]

When you want to commit something in your branch, be sure to be in your branch.

You can see all branches created by using :

$ git branch

Which will show :

* approval_messages
  master
  master_clean

Add a new remote for your branch :

$ git remote add [name_of_your_remote] 

Push changes from your commit into your branch :

$ git push origin [name_of_your_remote]

Update your branch when the original branch from official repository has been updated :

$ git fetch [name_of_your_remote]

Then you need to apply to merge changes, if your branch is derivated from develop you need to do :

$ git merge [name_of_your_remote]/develop

Delete a branch on your local filesystem :

$ git branch -d [name_of_your_new_branch]

To force the deletion of local branch on your filesystem :

$ git branch -D [name_of_your_new_branch]

Delete the branch on github :

$ git push origin :[name_of_your_new_branch]

The only difference is the : to say delete, you can do it too by using github interface to remove branch : https://help.github.com/articles/deleting-unused-branches.

If you want to change default branch, it's so easy with github, in your fork go into Admin and in the drop-down list default branch choose what you want.

回答: 在GitHub上合并分支到主分支的步骤如下: 1. 首先,确保你已经将分支的代码提交并推送到远程仓库。 2. 在GitHub上打开你的仓库页面,点击"Pull requests"选项卡。 3. 点击"New pull request"按钮创建一个新的合并请求。 4. 在合并请求页面,选择要合并的分支和主分支。 5. 确认合并请求的标题和描述,并点击"Create pull request"按钮提交合并请求。 6. 接下来,由项目的维护者或其他有权限的人员进行代码审查,并在必要时提出修改意见。 7. 一旦代码审查通过,点击"Merge pull request"按钮将分支的代码合并到主分支。 8. 最后,点击"Confirm merge"按钮确认合并操作。 通过以上步骤,你就可以成功将分支的代码合并到主分支了。\[1\] #### 引用[.reference_title] - *1* [多人协作开发,如何将自己分支代码合并到主分支](https://blog.youkuaiyun.com/W2457307263/article/details/128859584)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [新建分支并且提交、合并到主分支上面(关于github操作)](https://blog.youkuaiyun.com/xiaojinguniang/article/details/87996632)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值