mukhilsaravanan
mukhilsaravanan

Reputation: 135

How to pull and merge changes into current branch from master?

I am working on a branch called create. I have to pull the changes that are made into my branch. I already have done -

git checkout master

git pull origin master

and now I have to merge it. What's the way to merge it?

Upvotes: 11

Views: 32065

Answers (3)

sa77
sa77

Reputation: 3603

It is recommended to rebase your feature branch with master rather than merge it. Details below

rebase - if you are still working on your feature branch create, then rebase your feature branch to master. This allows you to work on your branch with the latest version of master as if you've just branched off your master.

git checkout create
git rebase master

merge - use it when you finish your task on your feature branch and want to merge it to other branches. For example, when you finish your work on create branch and want to merge it with master.

git checkout master
git merge create
git push origin master

This operation also generates a merge commit on your master branch.

Upvotes: 6

Naman
Naman

Reputation: 32036

Considering that you have updated the master on your local using

git checkout master && git pull origin master

You can pull the changes to create branch also using -

git checkout create && git pull origin master

Edit - As suggested by @Zarwan, rebase is also another option. For details on when to use which, please look into When do you use git rebase instead of git merge?

Upvotes: 9

Zarwan
Zarwan

Reputation: 5797

git checkout create

git rebase origin master

This will take the changes on your branch and apply them on top of the current master branch, and your branch will be updated to point to the result. In other words, master will be merged into create.

Upvotes: 2

Related Questions