From 627c501a84c9e7e67f720c242952f6e28698683f Mon Sep 17 00:00:00 2001 From: Julien Jerphanion Date: Sun, 24 Aug 2025 18:30:59 +0200 Subject: [PATCH] Add `-u` short option for `git pull` Add the short form `-u` as an alias for `--set-upstream` in `git pull`, similarly to `git push` which supports both forms. This allows users to use `git pull -u ` as a shorter alternative to `git pull --set-upstream `. One test is included to verify that the short form works correctly and set the upstream configuration as expected. Signed-off-by: Julien Jerphanion --- builtin/pull.c | 2 +- t/t5553-set-upstream.sh | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/builtin/pull.c b/builtin/pull.c index 5ebd5296207061..e09f2963f78912 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -254,7 +254,7 @@ static struct option pull_options[] = { 0), OPT_BOOL(0, "show-forced-updates", &opt_show_forced_updates, N_("check for forced-updates on all updated branches")), - OPT_PASSTHRU(0, "set-upstream", &set_upstream, NULL, + OPT_PASSTHRU('u', "set-upstream", &set_upstream, NULL, N_("set upstream for git pull/fetch"), PARSE_OPT_NOARG), diff --git a/t/t5553-set-upstream.sh b/t/t5553-set-upstream.sh index 70e3376d31b431..b4dd7c62ce9c59 100755 --- a/t/t5553-set-upstream.sh +++ b/t/t5553-set-upstream.sh @@ -124,6 +124,13 @@ test_expect_success 'pull --set-upstream upstream main sets branch main but not check_config_missing other ' +test_expect_success 'pull -u upstream main sets branch main but not other' ' + clear_config main other && + git pull --no-rebase -u upstream main && + check_config main upstream refs/heads/main && + check_config_missing other +' + test_expect_success 'pull --set-upstream main:other2 does not set the branch other2' ' clear_config other2 && git pull --no-rebase --set-upstream upstream main:other2 &&