Tldr: Add upstream config to Contributing.MD

Created on 18 Oct 2017  路  12Comments  路  Source: tldr-pages/tldr

The command line section is missing a step. After the contributor creates a feature branch locally they need to set the remote upstream or else attempts to push will fail.

Example:

git push --set-upstream origin {{feature_branch_name}}

documentation

Most helpful comment

I see the issue. This is a change in git behavior.

20:37:08-agniva-~/Downloads/tldr$git push 
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

Earlier, by default, git push meant git push origin <current_branch>. But now, that does not seem to be the case. Thanks for bringing to notice.

This does not need the --set-upstream flag however. A simple git push origin <branch> is sufficient. Hence, my confusion earlier.

I will update the page.

All 12 comments

Hi @lamar-frankie,

I am a bit confused. --set-upstream or -u is used to set the remote branch name when pushing. This is used in case when your local branch is different from the remote branch where you want to push. But you are saying unless the -u is set, attempts to push will fail. I have personally never seen this.

Also, you are interchangeably using the words remote upstream with remote branch. Your command invocation should actually be git push origin -u remote_branch.

Are you sure your local and remote branches have the same name and the remote is set properly ?

@agnivade In my opinion what @lamar-frankie wants to say is
git push origin {{feature_branch_name}}
The walk through given in the CONTRIBUTING.md first instructs to fork the main repo, then create a local branch for modification and fiinally push to the fork.
Then create a pull request from it.

The guide just uses git push instead of git push origin {{feature_branch}} which fails if you dont already have a {{feature_branch}} in the local fork.

Following the steps on the Contributing page gives you a local branch that isn't connected to a remote.

I see the issue. This is a change in git behavior.

20:37:08-agniva-~/Downloads/tldr$git push 
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

Earlier, by default, git push meant git push origin <current_branch>. But now, that does not seem to be the case. Thanks for bringing to notice.

This does not need the --set-upstream flag however. A simple git push origin <branch> is sufficient. Hence, my confusion earlier.

I will update the page.

@agnivade ohh are you going to update the page yourself,
actually, I had almost made a pr.
Should I continue with the pr or you would do the changes yourself?

cheers

Sure, please send a PR.

Running it with --set-upstream means that you don't have to use the full git push {{origin}} {{master}}, and instead you can use simply git push.

Yea it's a one-off thing. I prefer the full command since the page is going to be read by a lot of people using git for the first time.

With #1560, does that mean that this issue can be closed?

@sbrl I think we should close it

@mfrw Yeah, you're probably right. Closing now.

Ah, I forgot to add the "Closes" magic word in the PR.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

michaeldbianchi picture michaeldbianchi  路  3Comments

dikarel picture dikarel  路  3Comments

zlatanvasovic picture zlatanvasovic  路  3Comments

TobiasRoland picture TobiasRoland  路  3Comments

mebeim picture mebeim  路  3Comments