Skip to content

Commit c577d65

Browse files
alexhenriegitster
authored andcommitted
push: don't imply that integration is always required before pushing
In a narrow but common case, the user is the only author of a branch and doesn't mind overwriting the corresponding branch on the remote. This workflow is especially common on GitHub, GitLab, and Gerrit, which keep a permanent record of every version of a branch that is pushed while a pull request is open for that branch. On those platforms, force-pushing is encouraged and is analogous to emailing a new version of a patchset. When giving advice about divergent branches, tell the user about `git pull`, but don't unconditionally instruct the user to do it. A less prescriptive message will help prevent users from thinking that they are required to create an integrated history instead of simply replacing the previous history. Also, don't put `git pull` in an awkward parenthetical, because `git pull` can always be used to reconcile branches and is the normal way to do so. Due to the difficulty of knowing which command for force-pushing is best suited to the user's situation, no specific advice is given about force-pushing. Instead, the user is directed to the Git documentation to read about possible ways forward that do not involve integration. Signed-off-by: Alex Henrie <alexhenrie24@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent d92304f commit c577d65

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

builtin/push.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -301,21 +301,21 @@ static void setup_default_push_refspecs(int *flags, struct remote *remote)
301301

302302
static const char message_advice_pull_before_push[] =
303303
N_("Updates were rejected because the tip of your current branch is behind\n"
304-
"its remote counterpart. Integrate the remote changes (e.g.\n"
305-
"'git pull ...') before pushing again.\n"
304+
"its remote counterpart. If you want to integrate the remote changes,\n"
305+
"use 'git pull' before pushing again.\n"
306306
"See the 'Note about fast-forwards' in 'git push --help' for details.");
307307

308308
static const char message_advice_checkout_pull_push[] =
309309
N_("Updates were rejected because a pushed branch tip is behind its remote\n"
310-
"counterpart. Check out this branch and integrate the remote changes\n"
311-
"(e.g. 'git pull ...') before pushing again.\n"
310+
"counterpart. If you want to integrate the remote changes, use 'git pull'\n"
311+
"before pushing again.\n"
312312
"See the 'Note about fast-forwards' in 'git push --help' for details.");
313313

314314
static const char message_advice_ref_fetch_first[] =
315-
N_("Updates were rejected because the remote contains work that you do\n"
316-
"not have locally. This is usually caused by another repository pushing\n"
317-
"to the same ref. You may want to first integrate the remote changes\n"
318-
"(e.g., 'git pull ...') before pushing again.\n"
315+
N_("Updates were rejected because the remote contains work that you do not\n"
316+
"have locally. This is usually caused by another repository pushing to\n"
317+
"the same ref. If you want to integrate the remote changes, use\n"
318+
"'git pull' before pushing again.\n"
319319
"See the 'Note about fast-forwards' in 'git push --help' for details.");
320320

321321
static const char message_advice_ref_already_exists[] =
@@ -327,10 +327,10 @@ static const char message_advice_ref_needs_force[] =
327327
"without using the '--force' option.\n");
328328

329329
static const char message_advice_ref_needs_update[] =
330-
N_("Updates were rejected because the tip of the remote-tracking\n"
331-
"branch has been updated since the last checkout. You may want\n"
332-
"to integrate those changes locally (e.g., 'git pull ...')\n"
333-
"before forcing an update.\n");
330+
N_("Updates were rejected because the tip of the remote-tracking branch has\n"
331+
"been updated since the last checkout. If you want to integrate the\n"
332+
"remote changes, use 'git pull' before pushing again.\n"
333+
"See the 'Note about fast-forwards' in 'git push --help' for details.");
334334

335335
static void advise_pull_before_push(void)
336336
{

0 commit comments

Comments
 (0)