Skip to content

Commit c190ced

Browse files
moygitster
authored andcommitted
status: add advice on how to push/pull to tracking branch
Signed-off-by: Matthieu Moy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8c7a786 commit c190ced

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

remote.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1627,21 +1627,25 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
16271627

16281628
base = branch->merge[0]->dst;
16291629
base = shorten_unambiguous_ref(base, 0);
1630-
if (!num_theirs)
1630+
if (!num_theirs) {
16311631
strbuf_addf(sb,
16321632
Q_("Your branch is ahead of '%s' by %d commit.\n",
16331633
"Your branch is ahead of '%s' by %d commits.\n",
16341634
num_ours),
16351635
base, num_ours);
1636-
else if (!num_ours)
1636+
strbuf_addf(sb,
1637+
_(" (use \"git push\" to publish your local commits)\n"));
1638+
} else if (!num_ours) {
16371639
strbuf_addf(sb,
16381640
Q_("Your branch is behind '%s' by %d commit, "
16391641
"and can be fast-forwarded.\n",
16401642
"Your branch is behind '%s' by %d commits, "
16411643
"and can be fast-forwarded.\n",
16421644
num_theirs),
16431645
base, num_theirs);
1644-
else
1646+
strbuf_addf(sb,
1647+
_(" (use \"git pull\" to update your local branch)\n"));
1648+
} else {
16451649
strbuf_addf(sb,
16461650
Q_("Your branch and '%s' have diverged,\n"
16471651
"and have %d and %d different commit each, "
@@ -1651,6 +1655,9 @@ int format_tracking_info(struct branch *branch, struct strbuf *sb)
16511655
"respectively.\n",
16521656
num_theirs),
16531657
base, num_ours, num_theirs);
1658+
strbuf_addf(sb,
1659+
_(" (use \"git pull\" to merge the remote branch into yours)\n"));
1660+
}
16541661
return 1;
16551662
}
16561663

t/t2020-checkout-detach.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ test_expect_success 'checkout does not warn leaving reachable commit' '
151151

152152
cat >expect <<'EOF'
153153
Your branch is behind 'master' by 1 commit, and can be fast-forwarded.
154+
(use "git pull" to update your local branch)
154155
EOF
155156
test_expect_success 'tracking count is accurate after orphan check' '
156157
reset &&

0 commit comments

Comments
 (0)