Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you stay up-to-date in your feature branch (Git)?

Say that I've cloned the develop branch of a project. Then, off of develop, I branched and called it feature/abc.

As I work on my local feature/abc, clearly the point that I branched off of develop is going to get more and more behind from what develop currently looks like. Maybe I am fundamentally confused by the git process...

Does this mean that my feature/abc branch will fall more and more behind where develop currently is since it was branched off of an old version of develop? Is this just a part of the git process and you just have to resolve any and all conflicts that may arise AFTER you complete work on the local feature/abc, commit and push to the remote feature/abc, and then merge with develop?

Is there any way to pull in changes from develop without merging your work-in-progress changes on feature/abc? Or is the whole point of this that you should work on quick, easy changes that can be completed quickly and merged so your feature branch doesn't fall too behind?

like image 609
Takaji Messer Avatar asked Nov 18 '25 18:11

Takaji Messer


2 Answers

You can periodically pull in the changes from the develop branch...

git checkout develop
git pull
git checkout feature/abc
git merge develop

Now your feature/abc branch has the latest stuff from develop.

like image 166
Buddy Avatar answered Nov 20 '25 13:11

Buddy


You can update your feature branch periodically.

First you need to make sure you have the latest changes from the remote (assuming you have a remote repo)

git fetch origin

Then you need to merge those changes to the remote develop branch into your local develop branch

git checkout develop
git merge origin/develop

Note: This fetch/merge process does the same as doing a pull to the develop branch. I prefer to use fetch/merge as it gives me more control. For example if you wanted to see what commits had been added to develop before merging it with your local develop branch, you could do git checkout origin/develop then git log.

Finally you need to merge the local develop branch into your local feature branch

git checkout feature
git merge develop

This will merge the changes in the develop branch into your feature branch. No changes will be made to the develop branch.

like image 23
developerbmw Avatar answered Nov 20 '25 15:11

developerbmw



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!