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}}
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.
Most helpful comment
I see the issue. This is a change in git behavior.
Earlier, by default,
git pushmeantgit 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-upstreamflag however. A simplegit push origin <branch>is sufficient. Hence, my confusion earlier.I will update the page.