Reputation: 25917
Suppose I run:
git push
And I get the error message:
fatal: The current branch cdt-rd has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin cdt-rd
Is there a way to conjigger my git or bash so that it automatically copies the correct command (git push --set-upstream origin cdt-rd
) to my clipboard?
Upvotes: 1
Views: 73
Reputation: 1
git config --global push.default current
You should only have to do this once. Then,
git push
Upvotes: 0
Reputation: 4253
Would probably be easier to create a smart alias, I use this one:
git config --global alias.pto '!bash -c "git push --set-upstream ${1-origin} $(git symbolic-ref --short HEAD)" -'
Pushes to the origin by default git pto
or to another remote git pto remote
It automatically resolves the current branch name, then pushes the branch to the remote and sets the upstream. Also works if you use this command instead of push if the upstream is already set.
Upvotes: 2