Search code examples
gitgit-branchgit-pushgit-pull

How to get updates from master branch - which is correct and why


I have branch named "Development". I have created new branch named "New task".

Some developers commits to "Development" branch. In the other words it updates very common.

I'm working on branch named "new task".

Question 1.

Now I want update branch "new task". In the other words, the changes that was done in "Development" want to be in "new task" branch too. Is this correct way?

from "new_task"

git pull origin development

or can I do something like this? Is this same?

git checkout development
git pull
git checkout new_task 
git pull
git merge development

this final merge will create only local merge in 'new_task' branch, will not it?

Question 2.

Finally I want to merge development and "new task" branch. All of them are updated by developers. Is this correct not to have conflicts?

git checkout new_task
git pull 
git checkout development
git pull
git merge new_task
git push

Solution

  • Question 1.

    if you want to update your new_task branch, then I always use the second method. Switch to development, pull the changes there, and then switch back to new_task and merge development onto the top of that. That always worked for me.

    Question 2.

    If you want to merge all the changes you made in new_task onto the top of your development branch, then yes, this is the correct way to do this.

    Don't forget, the merge is one way only, so you only sync your stuff in the development branch this way.