0

I am reading through the magit manual trying to figure out how to configure remote variables.

From the magit manual "7.1.1 The Remote Popup" on https://magit.vc/manual/magit/The-Remote-Popup.html :

M C     (magit-remote-config-popup)
        This command shows remote related variables in a separate popup.

M a     (magit-remote-add)
        Add a remote and fetch it. The remote name and url are read in the minibuffer.

The 'M' menu does not list 'C'. How to access the 'C' option?

I have used git for a small project, now I am starting to learn magit.

I am using two github URLs for practice. The maintainer URL is https://github.com/wolfv6/repo.git . The contributor URL is https://github.com/wstudent/repo . How does the maintainer pull from the contributor's repo from magit?

I tried the following.

From Magit I enter Magit pull popup by pressing 'F':

enter image description here

Then press 'e':

enter image description here

What should go in the "Pull:" prompt?

Adding upstream from git command line looks like this:

[~/Documents/developer/git/canon/repo]
$ git remote -v
origin  https://github.com/wolfv6/repo.git (fetch)
origin  https://github.com/wolfv6/repo.git (push)
$ git remote add upstream https://github.com/wstudent/repo.git

Can Magit add upstream, or should I use git command line?

  • Just out of curiosity: how did you get into this situation? Did you create a local branch and now are trying to pull into it from somewhere? I'm not saying this is impossible, it just sounds like something not very useful. On your other question: M-x magit-remote-add will prompt you for remote's details and add it to the currently active repository. – wvxvw Dec 19 '17 at 9:54
  • @wvxvw, I added a description of my situation to the top of the question. The magit-remote-add manual entry says, "Add a remote and fetch it". magit.vc/manual/magit/The-Remote-Popup.html#The-Remote-Popup But I don't want to fetch, I want to pull. – wolfv Dec 19 '17 at 16:28
  • @wvxvw, now I see. "M a" menu has option "-f Fetch after add" (the manual is not up to date). – wolfv Dec 24 '17 at 5:03
  • OK, there's some confusion in terminology. Fetching in this case refers to fetching the metadata for the remote (i.e. what refs it has. refs are branches and tags, in the first approximation). This is different from fetching a branch, where the history of all commits needed to reproduce branch's history will be downloaded. Now, pull is a two-stage process (in this respect), it fetches the history of the branch and then it either merges that history with your local history, or it rebases fetched history on local history. (contd) – wvxvw Dec 25 '17 at 8:49
  • The typical process of working with branches of other people is that you (1) fetch their repository. (2) select the branch you want to work with. (3) pull that branch into the branch you created locally. Normally, this would be achieved by first checking out the branch, which will create a local branch tracking the remote branch. (4) work on the local branch. (5) merge or rebase your changes on the remote branch. (6) push your changes back to the original (upstream) repository. This is why, normally, you don't need to set a remote for your branch, it's set automatically at checkout. – wvxvw Dec 25 '17 at 8:53
2

Among other things the screenshot you posted contains this:

Configure
 C variables...

Press C. A new popup comes up that, among other things, contains:

Configure master
 u branch.master.merge       unset
   branch.master.remote      unset

These are the variables that you have to set to configure master's upstream. Press u. That will prompt for a branch and you should choose origin/master as value. Based on that value, both variables will be set.

  • Why would upstream be configured to origin/master? Shouldn't master's upstream be configured to upstream/master? There is something I am not understanding. My understanding is to push to origin/master and pull from upstream. – wolfv Dec 21 '17 at 3:23
  • your answer is probably correct. This is how did it: Since the maintainer will have multiple contributors, add upstream named after contributor using M a, then pull from upstream using F e and choose the upstream name. – wolfv Dec 25 '17 at 7:01
1

Simple answer: "upstream" isn't a special form of remote: just "add" the upstream repo as a remote named "upstream". Then you can configure it as a default pushRemote if you desire.

How to prove this for yourself:

If you add an upstream via the git command line, as you noted, with git remote add upstream <repo path>, and then you open up the magit remote dialogue by pressing M), the new remote will not appear in the initial dialogue. However, if you choose C to "Configure", and type "upstream" into the dialogue, it will show your upstream.

Then remove the upstream via command line: git remote remove upstream and add it again via magit M + a, type "upstream" as the remote name, and enter the repo path. It then give you the option of setting the new remote name "upstream" as the pushDefault. Choose wisely.

Now we're in an equivalent state as when you added it via the command line.

Now, there's a lot of confusion about basic git process in the comments, and it seems that specifically that folks don't understand what the concept of an upstream remote is. The most common scenario is: you fork a project. The original repo is designated as the "upstream" remote, while you forked copy is the "master". Now you can happily push and merge to your "master", and it won't affect the upstream. Until you're ready, then you can push to upstream, or open a pull request (i.e., on github) from your fork to the upstream.

  • There's an M C on your Magit? From my Magit status page, M C says "C isn't bound to any action". However, F C has configure variables, some of which are remote. Is that similar to M C? Also my M a behaves differently than you describe. From M a, Magit asked me for a remote name, I entered "upstream", and then asked me to enter a repo path. And my Magit menus are different than the Magit manual. Maybe something is wrong with my Magit install. I am on version 2.11.0, the latest version 2.12.0 was released yesterday. What version of Magit are you using? – wolfv Mar 30 '18 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.