@@ -64,14 +64,24 @@ static void set_refspecs(const char **refs, int nr)
64
64
}
65
65
}
66
66
67
- static void setup_push_upstream (void )
67
+ static void setup_push_upstream (struct remote * remote )
68
68
{
69
69
struct strbuf refspec = STRBUF_INIT ;
70
70
struct branch * branch = branch_get (NULL );
71
71
if (!branch )
72
- die ("You are not currently on a branch." );
72
+ die ("You are not currently on a branch.\n"
73
+ "To push the history leading to the current (detached HEAD)\n"
74
+ "state now, use\n"
75
+ "\n"
76
+ " git push %s HEAD:<name-of-remote-branch>\n" ,
77
+ remote -> name );
73
78
if (!branch -> merge_nr || !branch -> merge )
74
- die ("The current branch %s has no upstream branch." ,
79
+ die ("The current branch %s has no upstream branch.\n"
80
+ "To push the current branch and set the remote as upstream, use\n"
81
+ "\n"
82
+ " git push --set-upstream %s %s\n" ,
83
+ branch -> name ,
84
+ remote -> name ,
75
85
branch -> name );
76
86
if (branch -> merge_nr != 1 )
77
87
die ("The current branch %s has multiple upstream branches, "
@@ -80,7 +90,7 @@ static void setup_push_upstream(void)
80
90
add_refspec (refspec .buf );
81
91
}
82
92
83
- static void setup_default_push_refspecs (void )
93
+ static void setup_default_push_refspecs (struct remote * remote )
84
94
{
85
95
switch (push_default ) {
86
96
default :
@@ -89,7 +99,7 @@ static void setup_default_push_refspecs(void)
89
99
break ;
90
100
91
101
case PUSH_DEFAULT_UPSTREAM :
92
- setup_push_upstream ();
102
+ setup_push_upstream (remote );
93
103
break ;
94
104
95
105
case PUSH_DEFAULT_CURRENT :
@@ -147,7 +157,14 @@ static int do_push(const char *repo, int flags)
147
157
if (!remote ) {
148
158
if (repo )
149
159
die ("bad repository '%s'" , repo );
150
- die ("No destination configured to push to." );
160
+ die ("No configured push destination.\n"
161
+ "Either specify the URL from the command-line or configure a remote repository using\n"
162
+ "\n"
163
+ " git remote add <name> <url>\n"
164
+ "\n"
165
+ "and then push using the remote name\n"
166
+ "\n"
167
+ " git push <name>\n" );
151
168
}
152
169
153
170
if (remote -> mirror )
@@ -175,7 +192,7 @@ static int do_push(const char *repo, int flags)
175
192
refspec = remote -> push_refspec ;
176
193
refspec_nr = remote -> push_refspec_nr ;
177
194
} else if (!(flags & TRANSPORT_PUSH_MIRROR ))
178
- setup_default_push_refspecs ();
195
+ setup_default_push_refspecs (remote );
179
196
}
180
197
errs = 0 ;
181
198
if (remote -> pushurl_nr ) {
0 commit comments