Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need to checkout and pull a remote git branch before I merge it in?

My normal process for merging in develop to my feature\my-feature branch is:

name@home ~/myRepo (feature/my-feature)
$ git checkout develop
$ git pull
$ git checkout feature/my-feature
$ git merge develop
$ git mergetool

Can this be replaced with:

name@home ~/myRepo (feature/my-feature)
$ git fetch
$ git merge origin/develop
$ git mergetool

Does fetch retrieve enough information about the changes from the remote origin/develop to allow me to merge from origin/develop rather than develop?

Is it bad practice to have feature/my-feature ahead of develop with changes from the remote origin/develop?

like image 935
StuperUser Avatar asked Oct 19 '22 11:10

StuperUser


1 Answers

You can directly pull your remote branch develop, but you may need to mention the remote repository (in your case, origin):

git checkout feature
git pull origin develop

This will result in a merge commit, where the message mentions origin/develop.

Without mentioning the remote repo, I'm afraid that the merge part of the pull would merge your local branch develop, not the fetched one. But do try it!

like image 166
Gauthier Avatar answered Oct 22 '22 00:10

Gauthier