1

Say I have 2 branches: develop and feature-10. I'm working on feature-10 and once feature's development is done, I create a pull request.

When I get a merge conflict in PR creation, I do this (from feature-10 branch):

$ git checkout develop
$ git pull origin develop
$ git checkout feature-10
$ git merge develop

Is it possible to pull develop and merge into feature-10 in one step, instead of checkout and pull explicitly?

Héctor
  • 24,444
  • 35
  • 132
  • 243
  • Possible duplicate of [What is the exact difference when you execute \`git fetch upstream master:master\` vs \`git pull upstream master:master\`](https://stackoverflow.com/questions/49784394/what-is-the-exact-difference-when-you-execute-git-fetch-upstream-mastermaster) – phd Oct 05 '18 at 14:48
  • 1
    In your case the command is `$ git pull origin develop:develop`. – phd Oct 05 '18 at 14:49
  • 2
    @phd comment is correct, but I advise avoiding tricky stuff like this. Use `git fetch origin` to obtain all updates from `origin` into `origin/*`, then do individual `git merge` commands on individual branches that you care about. Mostly you won't even bother with a local `develop` branch at all when you work this way—you don't need a local `master` or `develop`, just your local `feature-10`. – torek Oct 05 '18 at 15:09

2 Answers2

2

No, this is not possible. The commands are individual and can not be combined, you can chain them with the && operator but it can't be done in one command.

Sven Hakvoort
  • 3,543
  • 2
  • 17
  • 34
1

As @Sven Hakvoort points out, the series of Git operations you want could be done by making use of chaining Git commands and then setting it as an alias for convenient access.

Define the alias in your .gitconfig file:

[alias]
pullmerge = !git checkout $1 && git pull origin $1 && git checkout $2 && git merge $1

Then you can use it like so:

git pullmerge develop feature-10

Naturally, if there are any merge conflicts, the alias won't be a smooth operation.

miqh
  • 3,624
  • 2
  • 28
  • 38