Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update develop branch from the master branch without losing any changes in develop

hi I have a develop branch based on master branch. I make changes in the develop branch. Now, my question is if the master branch is to be updated, how can I upgrade the develop branch based on the master branch Without losing my changes in develop branch?

like image 905
hadi khodabandeh Avatar asked Jan 27 '23 01:01

hadi khodabandeh


1 Answers

Depends on what you mean "upgrade", but I would assume you want your develop branch to have the commits master has.

So you need a git merge or a git rebase.

# merge master into develop
git checkout develop
git merge master

or

# rebase develop on top of master
git checkout develop
git rebase master

Or if your master is on a server and you want to get the changes from your origin, you can have to do the same things, but with the pull command.

git checkout develop
git pull #or git pull --rebase

Note that your current working directory must be clean. Otherwise you must commit (or stash) your changes, in order to get things from master.

like image 164
mnestorov Avatar answered Jan 29 '23 05:01

mnestorov