File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -394,6 +394,39 @@ To https://github.com/<your_github_username>/hello-world
394394
395395And let's check on GitHub that we now have 2 commits there.
396396
397+ ::::::::::::::::::::::::::::::::: challenge
398+
399+ ## Challenge: Two different push commands
400+
401+ The first time we pushed our changes, we used a longer command:
402+
403+ ``` bash
404+ $ git push -u origin main
405+ ```
406+
407+ The second time, we used a shorter command:
408+
409+ ``` bash
410+ $ git push
411+ ```
412+
413+ Why didn't we use the same command both times?
414+
415+ ::::::::::::::::: solution
416+
417+ Branches can be configured with an "upstream" branch (a branch on a remote repository),
418+ which is used automatically for ` push ` and ` pull ` operations.
419+
420+ The ` main ` branch's upstream wasn't set when we created it.
421+ The ` -u ` (or ` --set-upstream ` ) flag tells ` git push ` which remote branch to use;
422+ it also sets the remote branch as the local branch's upstream.
423+ Once we've set it, we don't need to specify the remote branch in future ` push ` and ` pull ` operations.
424+ This saves on typing and means we won't ` push ` to or ` pull ` from the wrong remote branch.
425+
426+ ::::::::::::::::::::::::::
427+
428+ :::::::::::::::::::::::::::::::::::::::::::
429+
397430## Pulling changes
398431
399432When working with others, or when we're making our own changes from different machines, we need a way of pulling those
Original file line number Diff line number Diff line change 66"index.md" "773cf78e1289f5ca1461848f3c59dfdb" "site/built/index.md" "2023-04-21"
77"episodes/01-what-is-git.md" "445007d28cfc4ea532840d493b6d10e6" "site/built/01-what-is-git.md" "2024-07-03"
88"episodes/02-getting-started.md" "a706fb1eba599733b9f6513b218fe017" "site/built/02-getting-started.md" "2024-07-03"
9- "episodes/03-sharing.md" "6e5e132d79497cf366995769a8b911c9 " "site/built/03-sharing.md" "2025-06-02 "
9+ "episodes/03-sharing.md" "2ebf04d7dbd6bb52bcd799fb62860d17 " "site/built/03-sharing.md" "2025-08-14 "
1010"episodes/04-review.md" "9e589dcefa2ff8f2d9ce79e2f5eda5df" "site/built/04-review.md" "2023-04-21"
1111"episodes/05-github-pages.md" "785565f4f08d619905fd0104496ce055" "site/built/05-github-pages.md" "2025-08-12"
1212"instructors/instructor-notes.md" "a45553efc112e3823f231cc16c2da968" "site/built/instructor-notes.md" "2023-04-21"
You can’t perform that action at this time.
0 commit comments