10

I was pushing my master branch to my GIT repo and go this error

  fatal: 'master' does not appear to be a git repository

On the advice of a stack question I typed

  git remote -v

and got

  heroku    https://git.heroku.com/peaceful-cove-8372.git (fetch)
  heroku    https://git.heroku.com/peaceful-cove-8372.git (push)
  origin    https://github.com/SimonWalsh1000/breathe.git (fetch)
  origin    https://github.com/SimonWalsh1000/breathe.git (push)

I then typed

   simonalice$ git push -u origin master

And it worked but said

   Branch master set up to track remote branch master from origin.

I am very new to GIT and I am not fully sure what has happened. I would be very grateful if someone could explain this sequence to me. I haven't been able to get clear answers. Is my master branch now, the master branch in GIT or is it some clone?

Many thanks

Nick Volynkin
  • 14,023
  • 6
  • 43
  • 67
GhostRider
  • 2,109
  • 7
  • 35
  • 53
  • My guess is that you initially ran `git push master`, which Git interprets as a request to push the current branch to a remote named `master`, rather than request to push the branch `master` to its default remote. – chepner Apr 23 '15 at 04:56
  • I think you are right. How would I get everything back the way it should be. Based upon the last response above - Branch master set up to track remote branch master from origin - does this mean the master on my computer and in GIT are the same thing? If not, how can I remedy this? – GhostRider Apr 23 '15 at 04:58
  • No, it just means that from now on (assuming `master` is checked out), that `git push` will behave like `git push origin master`. That is, unless you specify a different remote, the local branch `master` will be pushed to `origin`. You can always override it if you like, e.g., `git push heroku` to push to `heroku` instead of `origin`. I don't think there's anything you need to fix. – chepner Apr 23 '15 at 05:00

2 Answers2

8

I was getting the same error while doing git pull <branch>, and I fixed it by changing that to git pull origin <branch>.

Spencer Goff
  • 1,036
  • 3
  • 14
  • 23
6

And it worked but said

Branch master set up to track remote branch master from origin.

Do a git config --local -l

You will see that the local branch master is set to track the upstream branch origin/master

See "Difference between git checkout --track origin/branch and git checkout -b branch origin/branch".

It would be like you did:

git config branch.master.remote origin
git config branch.master.merge refs/heads/branch

The first push needs that upstream information: see "Why do I need to explicitly push a new branch?".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250