Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git remote not showing master or origin after git init

Tags:

git

I've created a new project with git init and added a remote for the master. Everything was working until I created a new branch "development" and I tried to push upstream to the master. I found it weird that I could not push/pull by calling out master but I was getting by not specifying the branch. That seems to now be a problem. Did I configure something wrong? According to the git documentation git remote should return two lines for the origin.

stephen@Desktop:~$ cd Projects/finance/
stephen@Desktop:~/Projects/finance$ git remote -v
stephen@Desktop:~/Projects/finance$ git branch
  development
* master

stephen@Desktop:~/Projects/finance$ git pull
From gitlab.com:sat5344/finance
 * branch            master     -> FETCH_HEAD
Already up to date.

stephen@Desktop:~/Projects/finance$ git pull master
fatal: 'master' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

stephen@Desktop:~/Projects/finance$ git pull origin
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

stephen@Desktop:~/Projects/finance$ git config -l
user.name=example_name
[email protected]
core.editor=emacs
color.branch=auto
color.diff=auto
color.interactive=auto
color.status=auto
color.grep=auto
alias.lol=log --graph --oneline --decorate --color --all
alias.logtable=log --pretty=format:%h - %an, %ar : %s --graph
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
[email protected]:sat5344/finance.git
branch.master.merge=refs/heads/master

stephen@Desktop:~/Projects/finance$ git pull master
fatal: 'master' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

stephen@Desktop:~/Projects/finance$ git pull origin master
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

stephen@Desktop:~/Projects/finance$ git push
fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using

    git remote add <name> <url>

and then push using the remote name

    git push <name>

stephen@Desktop:~/Projects/finance$ git push development
fatal: The current branch development has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream development development
  1. How do I correctly configure my git folder with a master and development branch?
  2. What is the difference between master and origin?
like image 779
sat1017 Avatar asked Jul 11 '26 19:07

sat1017


1 Answers

According to the output of git config -l you have no configured remotes. You need to add the remote:

git remote add origin [email protected]:sat5344/finance.git

Then give your local repo information about the remote's data:

git fetch origin

and then configure git so that the master branch tracks the origin/master

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

It is very unusual to see the line: [email protected]:sat5344/finance.git in your config, and I suspect you setup the remote by (incorrectly) hand editing one of the git config files.

"What is the difference between master and origin?" Everything. You could name a branch "origin" and you could also name a remote "master", but neither of those is a conventional name, so I will assume that you do not intend to have a branch named "origin", nor a remote named "master". In the usual convention, "master" is the name of your local branch. In your local repo, "origin/master" is the name of the branch "master" on the remote repository "origin". I feel as if this explanation is already confusing, so I'll cut it short with a brief synopsis: "master" is a branch, and "origin" is a repository. (With the caveat that those are merely conventional names. You could name a remote "master", and you could name a branch "origin", but it seems one would only do so in order to be intentionally confusing.)

like image 156
William Pursell Avatar answered Jul 14 '26 14:07

William Pursell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!