Git: autocomplete my prompt after failed push because missing -u flag
Using git, I often create local branches and then want to push them to the remote (e.g. Github). This requires the -u
or --set-upstream
flag.
Here is what git
outputs without this flag:
$ git checkout -b newbranch
$ git push
fatal: The current branch cross_val has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin newbranch
Is there a way to have this suggestion copied to my prompt? So that I don't have to type it. Something like:
$ git checkout -b newbranch
$ git push
fatal: The current branch cross_val has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin newbranch
$ <tab>
$ git push --set-upstream origin newbranch
bash git autocomplete
add a comment |
Using git, I often create local branches and then want to push them to the remote (e.g. Github). This requires the -u
or --set-upstream
flag.
Here is what git
outputs without this flag:
$ git checkout -b newbranch
$ git push
fatal: The current branch cross_val has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin newbranch
Is there a way to have this suggestion copied to my prompt? So that I don't have to type it. Something like:
$ git checkout -b newbranch
$ git push
fatal: The current branch cross_val has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin newbranch
$ <tab>
$ git push --set-upstream origin newbranch
bash git autocomplete
add a comment |
Using git, I often create local branches and then want to push them to the remote (e.g. Github). This requires the -u
or --set-upstream
flag.
Here is what git
outputs without this flag:
$ git checkout -b newbranch
$ git push
fatal: The current branch cross_val has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin newbranch
Is there a way to have this suggestion copied to my prompt? So that I don't have to type it. Something like:
$ git checkout -b newbranch
$ git push
fatal: The current branch cross_val has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin newbranch
$ <tab>
$ git push --set-upstream origin newbranch
bash git autocomplete
Using git, I often create local branches and then want to push them to the remote (e.g. Github). This requires the -u
or --set-upstream
flag.
Here is what git
outputs without this flag:
$ git checkout -b newbranch
$ git push
fatal: The current branch cross_val has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin newbranch
Is there a way to have this suggestion copied to my prompt? So that I don't have to type it. Something like:
$ git checkout -b newbranch
$ git push
fatal: The current branch cross_val has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin newbranch
$ <tab>
$ git push --set-upstream origin newbranch
bash git autocomplete
bash git autocomplete
asked Dec 10 at 16:07
Julien__
1032
1032
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You could set up an alias that pushes the current branch to the remote.
Configure the alias with the following command:
git config --global alias.rpush '!git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)'
The git rev-parse --abbrev-ref HEAD
command returns the name of your current branch. Then run it with:
git rpush
You can choose to give the alias any other name according to your own preference.
Thanks Haxiel, this will do
– Julien__
2 days ago
add a comment |
This won't do exactly what you want, but it will cut down the amount you need to type if you're using bash.
https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
I don't think this helps as the git completion scripts are already installed withgit
.
– Julien__
Dec 10 at 17:10
Guess it depends on the system. On my linux system it is a separate install and bashrc or profile needs to be updated to take advantage of it.
– user103944
Dec 11 at 18:34
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f487152%2fgit-autocomplete-my-prompt-after-failed-push-because-missing-u-flag%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You could set up an alias that pushes the current branch to the remote.
Configure the alias with the following command:
git config --global alias.rpush '!git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)'
The git rev-parse --abbrev-ref HEAD
command returns the name of your current branch. Then run it with:
git rpush
You can choose to give the alias any other name according to your own preference.
Thanks Haxiel, this will do
– Julien__
2 days ago
add a comment |
You could set up an alias that pushes the current branch to the remote.
Configure the alias with the following command:
git config --global alias.rpush '!git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)'
The git rev-parse --abbrev-ref HEAD
command returns the name of your current branch. Then run it with:
git rpush
You can choose to give the alias any other name according to your own preference.
Thanks Haxiel, this will do
– Julien__
2 days ago
add a comment |
You could set up an alias that pushes the current branch to the remote.
Configure the alias with the following command:
git config --global alias.rpush '!git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)'
The git rev-parse --abbrev-ref HEAD
command returns the name of your current branch. Then run it with:
git rpush
You can choose to give the alias any other name according to your own preference.
You could set up an alias that pushes the current branch to the remote.
Configure the alias with the following command:
git config --global alias.rpush '!git push --set-upstream origin $(git rev-parse --abbrev-ref HEAD)'
The git rev-parse --abbrev-ref HEAD
command returns the name of your current branch. Then run it with:
git rpush
You can choose to give the alias any other name according to your own preference.
answered Dec 10 at 17:23
Haxiel
994310
994310
Thanks Haxiel, this will do
– Julien__
2 days ago
add a comment |
Thanks Haxiel, this will do
– Julien__
2 days ago
Thanks Haxiel, this will do
– Julien__
2 days ago
Thanks Haxiel, this will do
– Julien__
2 days ago
add a comment |
This won't do exactly what you want, but it will cut down the amount you need to type if you're using bash.
https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
I don't think this helps as the git completion scripts are already installed withgit
.
– Julien__
Dec 10 at 17:10
Guess it depends on the system. On my linux system it is a separate install and bashrc or profile needs to be updated to take advantage of it.
– user103944
Dec 11 at 18:34
add a comment |
This won't do exactly what you want, but it will cut down the amount you need to type if you're using bash.
https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
I don't think this helps as the git completion scripts are already installed withgit
.
– Julien__
Dec 10 at 17:10
Guess it depends on the system. On my linux system it is a separate install and bashrc or profile needs to be updated to take advantage of it.
– user103944
Dec 11 at 18:34
add a comment |
This won't do exactly what you want, but it will cut down the amount you need to type if you're using bash.
https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
This won't do exactly what you want, but it will cut down the amount you need to type if you're using bash.
https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
answered Dec 10 at 16:49
user103944
163
163
I don't think this helps as the git completion scripts are already installed withgit
.
– Julien__
Dec 10 at 17:10
Guess it depends on the system. On my linux system it is a separate install and bashrc or profile needs to be updated to take advantage of it.
– user103944
Dec 11 at 18:34
add a comment |
I don't think this helps as the git completion scripts are already installed withgit
.
– Julien__
Dec 10 at 17:10
Guess it depends on the system. On my linux system it is a separate install and bashrc or profile needs to be updated to take advantage of it.
– user103944
Dec 11 at 18:34
I don't think this helps as the git completion scripts are already installed with
git
.– Julien__
Dec 10 at 17:10
I don't think this helps as the git completion scripts are already installed with
git
.– Julien__
Dec 10 at 17:10
Guess it depends on the system. On my linux system it is a separate install and bashrc or profile needs to be updated to take advantage of it.
– user103944
Dec 11 at 18:34
Guess it depends on the system. On my linux system it is a separate install and bashrc or profile needs to be updated to take advantage of it.
– user103944
Dec 11 at 18:34
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f487152%2fgit-autocomplete-my-prompt-after-failed-push-because-missing-u-flag%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown