Git: Update branch before checking out

Viewed 91

On the staging server, I have a branch checked out with the name develop currently with the latest code of dev changes. I merged this branch to the branch with the name master with live code in git. Now on the staging server, I want to checkout the newly updated master branch. So I do

git checkout master
git pull

This replaces with old code first and then with pull updates with new code. How can I get the latest updates in master branch first and then replace the code? I tried

git fetch 
git checkout master

But I still get the old code and need to pull it later.

1 Answers

You can do git rebase origin/master. This will update your current branch with the changes in the remote master branch.

Related