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 b53
the 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 ofchatbot
. - Merge
more-speech
intomaster
. - Push
master
to the remote repo
~$ cd /home/dq/chatbot
~$ git checkout master
~$ git merge more-speech
~$ git push origin master