Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add git fetch command to pull changes from the fork before setting local repo to track origin/master #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bytrangle
Copy link

@bytrangle bytrangle commented Mar 16, 2021

When I attempted to set up my local master branch to track the personal copy origin/master at my fork with the command:

git branch --set-upstream-to origin/master

I got an error “The requested upstream branch 'origin/master' does not exist”.

I believe the reason is that we haven't made a local copy of the branch named master on the remote named origin.

To see all the branches associated with the repo, run git branch -a. The output is as followed:

* master
  remotes/upstream/HEAD -> upstream/master
  remotes/upstream/exercise10
  remotes/upstream/exercise2
  remotes/upstream/exercise3
  remotes/upstream/exercise4
  remotes/upstream/exercise5
  remotes/upstream/exercise6
  remotes/upstream/exercise7
  remotes/upstream/exercise9
  remotes/upstream/master

Git is not aware of any origin/master branch at this point.

If I run either of these two commands: git fetch origin, or git push -u origin master, then run git branch -a again, the output is the same as above, but including an extra line: remotes/origin/master.

Then run git branch --set-upstream-to origin/master, then it works as expected with the message: “Branch 'master' set up to track remote branch 'master' from 'origin'.”

Hence, I propose that in the Solution section for exercise 8, we add the git fetch command before git branch --set-upstream-to so that other learns who follow it won't be caught off guard.

If not running this command before `git branch --set-upstream-to origin/master`, the origin/master branch doesn't exist yet in the remote repository. Hence, Git will throw an error: "The requested upstream branch 'origin/develop' does not exist.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant