How to Pull/Merge Changes from One Branch to Another in Git?

How to Pull/Merge Changes from One Branch to Another in Git?

How to Pull/Merge Changes from One Branch to Another in Git?

Suppose you have a branch called branch_feature and you want to pull or merge the changes from another branch (says branch_abc).

Here is the step-by-step procedure you should follow.

It’s very simple. We are simply using basic git commands.

Step 1: Make both the local branches up to date.

Check out the branch_abc and update the changes.

git checkout branch_abc
git pull

Check out the branch_feature and update the changes.

git checkout branch_feature
git pull

Now you have both the branches are up to date.

Step 2: Merge branch_abc with branch_feature

Make sure, you are currently on branch_feature. You can check the current branch using git status command.

git status

Now pull and merge the changes from branch_abc using the following git merge command.

git merge branch_abc

That’s all. Now you have all the changes in your branch_feature from the branch_abc.

Step 3: Push the changes to the remote repository

Remember, currently you have all the changes locally. You have to push that to the remote branch.

If there is any conflict you have to resolve that. After that, you are free to push your code to the remote branch.

Simply, use the git push command.

git push

Mission accomplished!

Also learn: Merge local branch with the master without missing local changes

If you have any challenges to merge changes from one branch to another in Git, feel free to ask. Happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *