-3

In a way completely detached from those commands in Git, Magit displays this:

Head:     heroku-master Added curl-based test, GPG and bulk inserts
Merge:    heroku/master Added curl-based test, GPG and bulk inserts
Push:     github/heroku-master is missing

And in the branch popup:

Configure existing branches
 d branch.heroku-master.description unset
 u branch.heroku-master.merge       refs/heads/master
   branch.heroku-master.remote      heroku
 r branch.heroku-master.rebase      [true|false|pull.rebase:true]
 p branch.heroku-master.pushRemote  [github|heroku|remote.pushDefault:github]

Configure repository defaults
 M-r pull.rebase        [true|false|global:true]
 M-p remote.pushDefault [github|heroku]

Configure branch creation
 U branch.autoSetupMerge  [always|true|false|default:true]
 R branch.autoSetupRebase [always|local|remote|never|default:never]

And in push popup:

Switches
 -f Force (--force-with-lease)
 -h Disable hooks (--no-verify)
 -d Dry run (--dry-run)

Push heroku-master to
 p github/heroku-master
 u heroku/master
 e elsewhere

Why would I ever want to press p from this buffer? I.e. why would I ever not want to push to the tracked branch? And why is it called "push"?

Notice also how Git is set to always rebase and not merge, but Magit displays "Merge". And, again, this has nothing to do with merging in Git or with any sort of merging you can think of...

I've seen this answer: https://emacs.stackexchange.com/a/26248/563 and it contradicts what I see in the status buffer. So, is this a bug or yet another "useful" feature? Is there any way to get rid of it?

wvxvw
  • 11,222
  • 2
  • 30
  • 55
  • 'my question was more of "how to get rid of this junk?", and the why it is misnamed is just a curiosity' - consider giving a more relevant title then. – npostavs Jun 06 '17 at 18:26
  • Okay everyone, this exchange got a bit too heated. Let's all cool off. – Dan Jun 07 '17 at 04:49

2 Answers2

7

This feature isn't "completely detached from those commands in Git". Git has this feature too, it is just hidden deep in the documentation. It also did not exist at the time the tutorials we all learned Git from, were written. So most Git users missed out on learning about it then, and most Git users haven't heard about it since. But it is very useful nonetheless.

Let's assume your local branch is cool-unfinished-feature. Eventually you want to merge that into master and then push master to origin/master. However you are not quite ready to do that yet, and meanwhile want to see a list of commits that are in cool-unfinished-features but not {origin/}master. Setting the upstream to one of these branches allows you to do so.

However you also want to push cool-unfinished-feature somewhere, so that others can review it, or, if you are not the maintainer, then you need to do that so that the maintainer can merge.

So you might set the upstream to my-fork/cool-unfinished-feature instead. This allows you to see what new commits on cool-unfinished-features you haven't pushed to my-fork/cool-unfinished-feature yet, i.e. what new additions others did not have a change to review yet. This also makes it easier to push to the ephemeral branch on the remote.

Unfortunately now you cannot see the full list of commits that have not been merged into origin/master yet anymore. Nor can you see the changes that have been made in the mainline, since you started working on your feature branch.

So you really want to be able to associate a feature branch with two related branches - (a) the branch into which it should eventually be merged (b) the public copy others can look at.

Git supports that. The upstream branch, which is configured using branch.<name>.remote and branch.<name>.merge should be used used for the "branch into which this should be merged eventually". And the push-remote should be used to configure where you want to push the ephemeral branch. This second mechanism only lets you specify the remote where you want to push the branch to, using branch.<name>.pushRemote or remote.pushDefault. The name of the remote branch is always the same on the remote as it is locally.

For a very few branches, e.g. master, the upstream and the push-remote usually refer to the same remote branch.

This is also discussed in the manual.

tarsius
  • 25,298
  • 4
  • 69
  • 109
  • Your assumption falls apart at the very start: no, that's not useful, and no, I would never want to do anything like that and cannot see why anyone would. Git is 90% of useless features. And this one is a pinnacle of uselessness... I can accomplish this task in about ten different ways, I don't need the eleventh way to do this. Why bring this garbage into Magit? Anyways, my question was more of "how to get rid of this junk?", and the why it is misnamed is just a curiosity. – wvxvw Jun 06 '17 at 06:02
  • 1
    As always with Magit, different people have different needs. I use this particular feature on a daily basis, and appreciate the heck out of it. I can also understand someone not needing it and even wishing to simplify the UI, but it's just silly to state that it's useless -- at minimum you can tell that it was useful enough *to some people* to warrant the effort being put into implementing the functionality in the first place. – phils Jun 06 '17 at 10:34
  • 6
    @wvxvw You should learn to treat the maintainers of the software that you use with respect. You are unwilling and/or incapable to understand that just because you do see no need for something doesn't mean that it is a "pinnacle of uselessness" - and need to put a serious effort into changing that attitude. You had this discussion before. You think Git is mostly stupid and Magit should "fix" that. But Magit was written for users who like Git or at least do not think it is only 10% good. Please stop using Magit, it is not a suitable tool for you. – tarsius Jun 06 '17 at 15:06
  • 3
    You have asked 5 questions about Magit so far. In 2 cases you were outright mean spirited and in 1 additional one slightly insulting. I will no longer answer your questions. https://emacs.stackexchange.com/questions/18924/new-magit-interface-no-actual-push was about essentially the same issue, and there too you quickly became insulting (though later you deleted the insults). – tarsius Jun 06 '17 at 15:10
  • I should act more professionally and simply ignore you, but your consistently insulting behavior makes that very hard. Here is a copy of your insults, in case you decide to remove the context, which would make my response look even worse>> – tarsius Jun 06 '17 at 15:17
  • @wvxvw said>> Your assumption falls apart at the very start: no, that's not useful, and no, I would never want to do anything like that and cannot see why anyone would. Git is 90% of useless features. And this one is a pinnacle of uselessness... I can accomplish this task in about ten different ways, I don't need the eleventh way to do this. Why bring this garbage into Magit? Anyways, my question was more of "how to get rid of this junk?", and the why it is misnamed is just a curiosity. – tarsius Jun 06 '17 at 15:17
  • @phils To see the same information you can use `git branch --contains `. If you want to chose where to push your changes, you can always use `e` button in the push buffer. This is the general problem with Git: abysmal documentation produces countless unneeded ways people start using this program, and then they keep at it for historical reason. This later becomes an administrator's nightmare. – wvxvw Jun 06 '17 at 15:22
  • @tarsius I never removed any of my comments, unless they were technical and meant for removal, as well as I never downoved anyone or used any administrative tools to prevent users of this site from having access to any information that was within my ability. The comments must have been deleted by moderators. Anyways, I really dislike the way you manage Magit, and I make no secret of it. If you find this insulting--that is your problem. – wvxvw Jun 06 '17 at 15:25
  • In that case, in the slim hope that it will make a difference, I'll add my own POV as a bystander: @wvxvw your attitude is terrible, and that is *your* problem, because seemingly you cannot see this for yourself. You do indeed come across as offensive, and lacking any respect for the (huge) effort that has gone into this software, and with no willingness to accept other viewpoints or to be constructive. The maintainers have regularly gone above and beyond in response to *constructive criticism*, but you make no effort. You should think carefully about the way you interact with people. – phils Jun 06 '17 at 22:43
  • @phils There's a general confusion between what it means to insult anyone and to criticize anyone. To insult is to deny your subject the basic dignity (eg. calling them "an idiot"). To criticize is to point out a flaw. I don't know Tarsius enough to say anything insulting about him. What I do know, is the project he works on, and that is the subject of my discontent. When I write anything about Magit, I'm by definition criticizing. I cannot be insulting. Also, asking to remove a useless feature isn't really non-constructive: the suggestion for improvement is on the surface. – wvxvw Jun 07 '17 at 06:21
4

Tarsius' answer already covers what it means and why it could be useful, but for completeness:

Is there any way to get rid of it?

(remove-hook 'magit-status-headers-hook #'magit-insert-upstream-branch-header)
(remove-hook 'magit-status-headers-hook #'magit-insert-push-branch-header)
npostavs
  • 9,033
  • 1
  • 21
  • 53