{"thread":{"id":"64029","subject":"[PATCH] Add `-u` short option for `git pull`","startedAt":"2025-08-25T18:49:53Z","lastAt":"2025-09-18T07:42:35Z","messageCount":6,"participants":["Julien Jerphanion via GitGitGadget","D. Ben Knoble","Junio C Hamano","Julien Jerphanion"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"524878","messageId":"pull.2037.git.git.1756147789443.gitgitgadget@gmail.com","threadId":"64029","inReplyTo":null,"subject":"[PATCH] Add `-u` short option for `git pull`","fromName":"Julien Jerphanion via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2025-08-25T18:49:48Z","receivedAt":"2025-08-25T18:49:53Z","isPatch":true,"sender":{"key":"git@jjerphan.xyz","avatar":"https://gravatar.com/avatar/acbff774c4b696257991dd616c48cf8f2d7fc5f1b3e6732305b27e503a7172f2?d=mp&s=160"},"body":"From: Julien Jerphanion <git@jjerphan.xyz>\n\nAdd the short form `-u` as an alias for `--set-upstream`\nin `git pull`, similarly to `git push` which supports both forms.\n\nThis allows users to use `git pull -u <remote> <branch>` as a\nshorter alternative to `git pull --set-upstream <remote> <branch>`.\n\nOne test is included to verify that the short form works\ncorrectly and set the upstream configuration as expected.\n\nSigned-off-by: Julien Jerphanion <git@jjerphan.xyz>\n---\n    Add -u short option for git pull\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2037%2Fjjerphan%2Fpull%2Fset-upstream-short-option-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2037/jjerphan/pull/set-upstream-short-option-v1\nPull-Request: https://github.com/git/git/pull/2037\n\n builtin/pull.c          | 2 +-\n t/t5553-set-upstream.sh | 7 +++++++\n 2 files changed, 8 insertions(+), 1 deletion(-)\n\ndiff --git a/builtin/pull.c b/builtin/pull.c\nindex 5ebd5296207..e09f2963f78 100644\n--- a/builtin/pull.c\n+++ b/builtin/pull.c\n@@ -254,7 +254,7 @@ static struct option pull_options[] = {\n \t\t0),\n \tOPT_BOOL(0, \"show-forced-updates\", &opt_show_forced_updates,\n \t\t N_(\"check for forced-updates on all updated branches\")),\n-\tOPT_PASSTHRU(0, \"set-upstream\", &set_upstream, NULL,\n+\tOPT_PASSTHRU('u', \"set-upstream\", &set_upstream, NULL,\n \t\tN_(\"set upstream for git pull/fetch\"),\n \t\tPARSE_OPT_NOARG),\n \ndiff --git a/t/t5553-set-upstream.sh b/t/t5553-set-upstream.sh\nindex 70e3376d31b..b4dd7c62ce9 100755\n--- a/t/t5553-set-upstream.sh\n+++ b/t/t5553-set-upstream.sh\n@@ -124,6 +124,13 @@ test_expect_success 'pull --set-upstream upstream main sets branch main but not\n \tcheck_config_missing other\n '\n \n+test_expect_success 'pull -u upstream main sets branch main but not other' '\n+\tclear_config main other &&\n+\tgit pull --no-rebase -u upstream main &&\n+\tcheck_config main upstream refs/heads/main &&\n+\tcheck_config_missing other\n+'\n+\n test_expect_success 'pull --set-upstream main:other2 does not set the branch other2' '\n \tclear_config other2 &&\n \tgit pull --no-rebase --set-upstream upstream main:other2 &&\n\nbase-commit: 1fa68948c3d76328236cac73d2adf33c905bd8e3\n-- \ngitgitgadget\n"},{"id":"524944","messageId":"CALnO6CC7+JC-EwEDZE1+rbr4ZMPs+dc_9iepb17_9Uda7GSRgw@mail.gmail.com","threadId":"64029","inReplyTo":"pull.2037.git.git.1756147789443.gitgitgadget@gmail.com","subject":"Re: [PATCH] Add `-u` short option for `git pull`","fromName":"D. Ben Knoble","fromEmail":"ben.knoble@gmail.com","sentAt":"2025-08-26T13:19:46Z","receivedAt":"2025-08-26T13:20:01Z","isPatch":true,"sender":{"key":"ben.knoble@gmail.com","avatar":"https://avatars.githubusercontent.com/u/22802209?v=4"},"body":"On Mon, Aug 25, 2025 at 2:50 PM Julien Jerphanion via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n>\n> From: Julien Jerphanion <git@jjerphan.xyz>\n>\n> Add the short form `-u` as an alias for `--set-upstream`\n> in `git pull`, similarly to `git push` which supports both forms.\n>\n> This allows users to use `git pull -u <remote> <branch>` as a\n> shorter alternative to `git pull --set-upstream <remote> <branch>`.\n>\n> One test is included to verify that the short form works\n> correctly and set the upstream configuration as expected.\n>\n> Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>\n> ---\n>     Add -u short option for git pull\n>\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2037%2Fjjerphan%2Fpull%2Fset-upstream-short-option-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2037/jjerphan/pull/set-upstream-short-option-v1\n> Pull-Request: https://github.com/git/git/pull/2037\n>\n>  builtin/pull.c          | 2 +-\n>  t/t5553-set-upstream.sh | 7 +++++++\n>  2 files changed, 8 insertions(+), 1 deletion(-)\n>\n> diff --git a/builtin/pull.c b/builtin/pull.c\n> index 5ebd5296207..e09f2963f78 100644\n> --- a/builtin/pull.c\n> +++ b/builtin/pull.c\n> @@ -254,7 +254,7 @@ static struct option pull_options[] = {\n>                 0),\n>         OPT_BOOL(0, \"show-forced-updates\", &opt_show_forced_updates,\n>                  N_(\"check for forced-updates on all updated branches\")),\n> -       OPT_PASSTHRU(0, \"set-upstream\", &set_upstream, NULL,\n> +       OPT_PASSTHRU('u', \"set-upstream\", &set_upstream, NULL,\n\nDon't forget to update the docs ;)\n\n>                 N_(\"set upstream for git pull/fetch\"),\n>                 PARSE_OPT_NOARG),\n>\n> diff --git a/t/t5553-set-upstream.sh b/t/t5553-set-upstream.sh\n> index 70e3376d31b..b4dd7c62ce9 100755\n> --- a/t/t5553-set-upstream.sh\n> +++ b/t/t5553-set-upstream.sh\n> @@ -124,6 +124,13 @@ test_expect_success 'pull --set-upstream upstream main sets branch main but not\n>         check_config_missing other\n>  '\n>\n> +test_expect_success 'pull -u upstream main sets branch main but not other' '\n> +       clear_config main other &&\n> +       git pull --no-rebase -u upstream main &&\n> +       check_config main upstream refs/heads/main &&\n> +       check_config_missing other\n> +'\n> +\n>  test_expect_success 'pull --set-upstream main:other2 does not set the branch other2' '\n>         clear_config other2 &&\n>         git pull --no-rebase --set-upstream upstream main:other2 &&\n>\n> base-commit: 1fa68948c3d76328236cac73d2adf33c905bd8e3\n> --\n> gitgitgadget\n>\n\n\n-- \nD. Ben Knoble\n"},{"id":"524956","messageId":"xmqqikiam90b.fsf@gitster.g","threadId":"64029","inReplyTo":"pull.2037.git.git.1756147789443.gitgitgadget@gmail.com","subject":"Re: [PATCH] Add `-u` short option for `git pull`","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-08-26T14:51:16Z","receivedAt":"2025-08-26T14:51:18Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Julien Jerphanion via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> From: Julien Jerphanion <git@jjerphan.xyz>\n>\n> Add the short form `-u` as an alias for `--set-upstream`\n> in `git pull`, similarly to `git push` which supports both forms.\n>\n> This allows users to use `git pull -u <remote> <branch>` as a\n> shorter alternative to `git pull --set-upstream <remote> <branch>`.\n\nThe above explains what it does.  It does not justify why it is\nneeded.  Surely it may allow them to type less, but is it something\nthey would do very often, like every other day or even twice an\nhour?  If not, should 'set-upstream' squat on a short-and-sweet 'u',\nrobbing it from future developers to use it for more useful purpose?\n\n"},{"id":"526601","messageId":"VVHyXy0fQW1fnBgiAFswUMEMMX4wnc3YIZWSRtSJzZbHOt0dfY0wCJt69MDxfue54cN2gPd8StlVtW2ERYKZcEs8Hpm7X5TaXrygCN2rK-A=@jjerphan.xyz","threadId":"64029","inReplyTo":"xmqqikiam90b.fsf@gitster.g","subject":"Re: [PATCH] Add `-u` short option for `git pull`","fromName":"Julien Jerphanion","fromEmail":"git@jjerphan.xyz","sentAt":"2025-09-17T16:21:12Z","receivedAt":"2025-09-17T16:21:21Z","isPatch":true,"sender":{"key":"git@jjerphan.xyz","avatar":"https://gravatar.com/avatar/acbff774c4b696257991dd616c48cf8f2d7fc5f1b3e6732305b27e503a7172f2?d=mp&s=160"},"body":"-------- Original Message --------\nOn 8/26/25 16:51, Junio C Hamano <gitster@pobox.com> wrote:\n\n>  \"Julien Jerphanion via GitGitGadget\" <gitgitgadget@gmail.com>\n>  writes:\n>  \n>  > From: Julien Jerphanion <git@jjerphan.xyz>\n>  >\n>  > Add the short form `-u` as an alias for `--set-upstream`\n>  > in `git pull`, similarly to `git push` which supports both forms.\n>  >\n>  > This allows users to use `git pull -u <remote> <branch>` as a\n>  > shorter alternative to `git pull --set-upstream <remote> <branch>`.\n>  \n>  The above explains what it does.  It does not justify why it is\n>  needed.  Surely it may allow them to type less, but is it something\n>  they would do very often, like every other day or even twice an\n>  hour?  If not, should 'set-upstream' squat on a short-and-sweet 'u',\n>  robbing it from future developers to use it for more useful purpose?\n>  \n>\n\nHello,\n\nBefore all, thank you for maintaining git!\n\nHaving this shortcut would be really useful for some use cases where one needs to pull locally branches from forks before updating them and pushing them again on the fork instead than on the upstream project (typical use case for conda-forge's feedstocks).\n\nJulien.\n"},{"id":"526648","messageId":"xmqqplboa9cb.fsf@gitster.g","threadId":"64029","inReplyTo":"VVHyXy0fQW1fnBgiAFswUMEMMX4wnc3YIZWSRtSJzZbHOt0dfY0wCJt69MDxfue54cN2gPd8StlVtW2ERYKZcEs8Hpm7X5TaXrygCN2rK-A=@jjerphan.xyz","subject":"Re: [PATCH] Add `-u` short option for `git pull`","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2025-09-18T00:32:52Z","receivedAt":"2025-09-18T00:32:55Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Julien Jerphanion <git@jjerphan.xyz> writes:\n\n[jc: line-wrapped an overly long single line]\n\n> Having this shortcut would be really useful for some use cases\n> where one needs to pull locally branches from forks before\n> updating them and pushing them again on the fork instead than on\n> the upstream project (typical use case for conda-forge's\n> feedstocks).\n\nSorry, do you mean that you stay on a single branch, and then you\nwould pull from one place with \"git pull -u\" followed by \"git push\"\nto push back there, and repeat that for other places, practically\nredefining the meaning of the \"upstream\" to \"the last remote\nrepository I pulled from and I am supposed to push to that remote\nand nowhere else in my workflow\"?\n\n"},{"id":"526681","messageId":"P018trwh6r7kRRrp99nCCDUdrKT3u7MvjNd_wUm2o2w3alWw4gpsvbEmp856xwAnMkuuLQBEUNfNxCU-K7xO0Zrw0Qsy5ZP5kOrDXjcwNQQ=@jjerphan.xyz","threadId":"64029","inReplyTo":"xmqqplboa9cb.fsf@gitster.g","subject":"Re: [PATCH] Add `-u` short option for `git pull`","fromName":"Julien Jerphanion","fromEmail":"git@jjerphan.xyz","sentAt":"2025-09-18T07:42:28Z","receivedAt":"2025-09-18T07:42:35Z","isPatch":true,"sender":{"key":"git@jjerphan.xyz","avatar":"https://gravatar.com/avatar/acbff774c4b696257991dd616c48cf8f2d7fc5f1b3e6732305b27e503a7172f2?d=mp&s=160"},"body":"-------- Original Message --------\nOn 9/18/25 02:32, Junio C Hamano <gitster@pobox.com> wrote:\n\n>  Julien Jerphanion <git@jjerphan.xyz> writes:\n>  \n>  [jc: line-wrapped an overly long single line]\n>  \n>  > Having this shortcut would be really useful for some use cases\n>  > where one needs to pull locally branches from forks before\n>  > updating them and pushing them again on the fork instead than on\n>  > the upstream project (typical use case for conda-forge's\n>  > feedstocks).\n>  \n>  Sorry, do you mean that you stay on a single branch, and then you\n>  would pull from one place with \"git pull -u\" followed by \"git push\"\n>  to push back there, and repeat that for other places, practically\n>  redefining the meaning of the \"upstream\" to \"the last remote\n>  repository I pulled from and I am supposed to push to that remote\n>  and nowhere else in my workflow\"?\n>  \n>\n\nMore or less, I was referring to the official repository in\nsuch workflows as `upstream`.\n\nI would also sporadically fetch and pull from `upstream`,\nbut I would not set local branches to tracks remote\nbranches there.\n\nAs a user, I find that having `-u` usable for the `pull`\ncommand would be consistent and expected given that\nit is present for other commands already.\n\nThank you for spending time considering this addition.\n"}]}