4: Merging Branches(Git branches)

When creating a project, it's typical for users to download and use a single version of the project. One example is Django, a popular web framework for Python, which is developed using git and Github. When a user installs Django, they install a single version, not dozens or hundreds of separate branches. However, if you look at the Github repo for Django, there are many different branches that have been used for development of features.Here's one such example, where a feature was developed on a separate branch.

Typically, the release that is downloaded and used is from the master branch. This means that all the changes made in other branches need to be pulled into the master branch. This can be done through a git concept called merging. Merging allows us to copy commits from one branch into another. This enables us to efficiently develop features for projects on their own branches, without conflicts, then merge them into master so that they're ready to be released and used.

In order to merge a branch into another branch, we can use the git merge command. Here's an example of a merge:

masterenhancementf34f34bot.pybot.pyprint(1)print(1)gitcommitb53b53gitmergebot.pybot.pyprint(2)print(2)

As you can see above, merging the branchenhancement into the branch master will pull the commit b53 into master, and make b53the latest commit in master. Whenever anyone switches to the branch master, their working directory will contain the file bot.py, which has the contents print(2).

In order to merge branch b into branch a, we first have to switch to branch a, then run git merge.

Merging allows us to efficiently combine changes from multiple branches into one, and have a working directory that reflects all the changes in all of the branches.

Instructions

  • Switch to the master branch of chatbot.
  • Merge more-speech into master.
  • Push master to the remote repo

~$ cd /home/dq/chatbot

~$ git checkout master

~$ git merge more-speech

~$ git push origin master

转载于:https://my.oschina.net/RobertPattins/blog/746978

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值