Merge a branch to main
Next, let’s merge the branch you just created (i.e., issue1
) along with its commit to main
.
To merge our commits into the main branch, we must first switch to the main branch.
$ git checkout main
Switched to branch 'main'
Before merging, open the myfile.txt
file and check the content of the file. You’ll see this:
Anyone can learn Git with this tutorial and Backlog
As you’ll see, the change added on issue1
we made in the previous step isn’t included in the myfile.txt
file on the main branch.
When you use the git merge command, the specified commit will merge with the active branch. Using the following command, we can now merge.
$ git merge issue1
Updating 1257027..b2b23c4
Fast-forward
myfile.txt | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
The position of the main branch will now move over to that of issue1
, executing a fast-forward merge.

Finally, let’s confirm the content of the myfile.txt
file. Open myfile.txt
, and you will see the new line we committed to the issue1
branch is now on the main branch.
Anyone can learn Git with this tutorial and Backlog
add: Register a change in an index