简体   繁体   中英

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?

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?

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM