Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you refresh the remotes in Magit?

Magit is really nice, but I have yet to figure out how to create a remote branch from it, or how to refresh the remote branches it knows without deleting the remote and adding it back in. Currently I go to github, add a branch, then go into magit, delete the remote, and then add it back. Is there a better way?

like image 623
user967953 Avatar asked Jun 14 '14 03:06

user967953


1 Answers

Refreshing a remote branch should be done with a git fetch.

With Magit (documentation):

Typing f f will run git fetch.
It will prompt for the name of the remote to update if there is no default one.

Typing f o will always prompt for the remote.

Typing F F will run git pull.
When you don’t have a default branch configured to be pulled into the current one, you will be asked for it.

As Rémi commented, f a would fetch all remotes.

Actually, as akaihola comments in 2018:

If you type F, you get the "pull" menu.
Then:

  • p pulls from the push default (see b M-p), and
  • e from elsewhere (e.g. another remote branch).

Creating a remote branch should be pushing a local branch to a remote:

Magit will run git push when you type P P.
If you give a prefix argument to P P, you will be prompted for the repository to push to.
When no default remote repository has been configured yet for the current branch, you will be prompted as well.

Typing P P will only push the current branch to the remote.
In other words, it will run git push <remote> <branch>.

The branch will be created in the remote if it doesn’t exist already.
The local branch will be configured so that it pulls from the new remote branch.

If you give a double prefix argument to P P, you will be prompted in addition for the target branch to push to.
In other words, it will run git push <remote> <branch>:<target>.

like image 67
VonC Avatar answered Oct 15 '22 10:10

VonC