Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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?

like image 936
mukhilsaravanan Avatar asked Nov 24 '16 04:11

mukhilsaravanan


2 Answers

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?

like image 125
Naman Avatar answered Oct 21 '22 10:10

Naman


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.

like image 24
sa77 Avatar answered Oct 21 '22 09:10

sa77