Joel
Joel

Reputation: 6243

Git merging remote branch to another remote branch - Best practice

Here's the scenario -

My normal workflow would be:

git checkout feature-branch

git fetch

git rebase (now my local is up to date with other's changes)

git checkout master

git rebase (now my master is up to date)

git merge feature-branch

git push (both updated master and local feature-branch are pushed)

I discovered that someone else on my team was doing things differently and were merging directly from remote/feature-branch to local/master.

What is the best practice here? Should we be using one method over another?

Upvotes: 0

Views: 821

Answers (1)

Justin Howard
Justin Howard

Reputation: 5643

The two operations are equivalent. If you merge from the remote though, you don't have to be careful that your local master branch is up to date.

My workflow is typically:

git checkout feature-branch
git fetch
git rebase # if there are upstream commits on the feature branch
git merge origin/master
git push

Upvotes: 1

Related Questions