Git merge

1.0K    Asked by AnushriSingh in Devops , Asked on Nov 29, 2019
Answered by Anushri Singh

Once the code of the new branch is tested to be working successful, you need to merge your new branch to the master branch(main branch)

Let’s first understand Git Branch –

Git branches are effectively a pointer to a snapshot of your changes.

Why is branching required?

When you want to add a new feature or fix a bug, it is not recommended to do changes directly to master branch(Main branch) to avoid the chances for unstable code to get merged into the main code base. So, you can create a new branch to encapsulate your changes.

It becomes convenient to work with multiple members in a team when each member is working on their own branch and when the code is tested to be working fine; branches can be merged to the main branch.

Steps and commands for Merging to master branch:

Checkout master branch - git checkout master

Merge new branch to master - git merge “branchName”

Push changes to remote repo - git push –u origin master


Your Answer

Interviews

Parent Categories