While working on a project, it is necessary to pull some branches from remote and merge into current branch.

To update another branch, we have to

  • Stash local changes on current branch
  • Checkout to required branch (say foo)
  • Pull changes
  • Switch back to previous branch
  • Pop stash

All these steps can be done with single command on terminal using

git fetch origin foo:foo

How to do the same with magit in single step?

  • : fetch origin foo:foo (not intended to be facetious -- I'm just pointing out that you can run arbitrary git commands from inside git). – phils Nov 30 '16 at 4:40

In addition to @phils valid observation, there is f o for fetch other, you can then give it origin and then foo. This will update the origin/foo branch, rather than the foo branch.

Or you can use f r for fetch refspec and give it origin and foo:foo which will do exactly what your command line does.

  • Excellent. Is it possible to auto populate foo:foo, instead of typing them everytime? – ChillarAnand Nov 30 '16 at 6:02
  • 2
    Is there a reason why you want to fetch just that one branch instead of everything? The current interface was designed with the assumptions that just fetching everything isn't much of a deal because it is more convenient to tell git "get it all" as opposed to "get... wait... ah yes, /this/". – tarsius Nov 30 '16 at 10:55
  • @tarsius It would be great if all remotes can be fetched at once. However i wanted all PR's of a repo, i have updated ` fetch = +refs/pull/*/head:refs/remotes/origin/pr/*` in git config. Now when i run f, r, origin, it just lists all available PR's and I have to type branch:branch everytime to fetch a branch. ` – ChillarAnand Dec 3 '16 at 15:33
  • @ChillarAnand f u will fetch all the configured branches, just like git fetch origin. – icarus Dec 3 '16 at 16:40

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .