Git - How to get the latest Branch a code from branch B without branching out


I am newbie to GIT. I am trying to figure out the answer for the below scenario.

I have user story say story1. There are two subtask for the user story 1) UI part 2) REST Code

We create a branch for the user story say feature/STORY1 Two teams are working on the STORY1. One on the UI part and other team on the REST part. So we created branches for feature/STORY1 say feature/STORY1-UI feature/STORY1-REST

feature/STORY1-UI feature/STORY1-REST are created under feature/STORY1.

My scenario: While I am working on STORY1-UI I need the latest code from STORY1-REST as my UI development needs the rest code. How can I get the latest code from STORY1-REST branch without switching my branch from STORY1-UI.

The best solution would have been not to split into sub branches.But since the branching is already done,I need a solution for this scenario.

Assuming you mean you want to get the REST code in the UI branch, you should just merge in REST. Make sure you've checked out the feature/STORY1-UI branch, and then run

git merge feature/STORY1-REST

Check out for the basics of branching and merging.